제출 #445063

#제출 시각아이디문제언어결과실행 시간메모리
445063Dipra_IrhamLutrija (COCI19_lutrija)C++14
63 / 70
266 ms292 KiB
#include "bits/stdc++.h" #define pb(x) push_back(x) #define fil(x, y) memset(x, y, sizeof(x)) #define ll long long #define ff first #define ss second #define printp(x) x.ff << " " << x.ss #define pii pair<int,int> #define pll pair<long long,long long> #define mp(x, y) make_pair(x,y) #define inf 1073741823 #define infll 4611686018427387903 #define M 1000000007 #define db(x) cout << x << " "; #define N 10000007 #define sz size #define sm 0.0000007 #define ins insert #define ers erase #define all(k) k.begin(), k.end() #define cnt count #define fastio ios_base::sync_with_stdio(0);cin.tie(0) using namespace std; bool chk(ll n) { ll sqrtn = sqrt(n + 1) + 1; bool g = 0; for(ll i = 2;i <= sqrtn && i < n;i++) { if(n % i == 0) { return 0; } } return 1; } int main() { fastio; ll a, b; cin >> a >> b; if(a == 2 && b == 2) { cout << 3 << endl; cout << 2 << " " << 5 << " " << 2 << endl; } else if(a % 2 == 1 && b % 2 == 1) { if(abs(b - a) == 2) { cout << 2 << endl; cout << a << " " << b << endl; return 0; } if(chk(a - 2) == 1 && (chk(b - 2) == 1)) { cout << 3 << endl; cout << a << " " << 2 << " " << b << endl; } else if(chk(a - 2) == 1 && chk(b + 2) == 1) { cout << 4 << endl; cout << a << " " << 2 << " " << b + 2 << " " << b << endl; } else if(chk(a + 2) == 1 && chk(b - 2) == 1) { cout << 4 << endl; cout << a << " " << a + 2 << " " << 2 << " " << b << endl; } else if(chk(a + 2) == 1 && chk(b + 2) == 1) { cout << 5 << endl; cout << a << " " << a + 2 << " " << 2 << " " << b + 2 << " " << b << endl; } else cout << -1 << endl; } else { ll n = abs(b - a); if(chk(n) == 1) { cout << 2 << endl; cout << a << " " << b << endl; } else { vector <ll> mn; ll x = a; ll y = b; if(a % 2 == 0) swap(a, b); if(chk(a + 2)) mn.pb(a + 2); if(chk(a - 2)){ mn.pb(a - 2); } bool g = 0; for(int i = 0;i < mn.sz();i++) { if(chk(abs(mn[i] - b)) == 1) { cout << 3 << endl; cout << x << " " << mn[i] << " " << y << endl; g = 1; break; } } if(g == 0) cout << -1 << endl; } } return 0; }

컴파일 시 표준 에러 (stderr) 메시지

lutrija.cpp: In function 'bool chk(long long int)':
lutrija.cpp:30:10: warning: unused variable 'g' [-Wunused-variable]
   30 |     bool g = 0;
      |          ^
lutrija.cpp: In function 'int main()':
lutrija.cpp:102:29: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  102 |             for(int i = 0;i < mn.sz();i++)
      |                           ~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...