Submission #666624

#TimeUsernameProblemLanguageResultExecution timeMemory
666624Koful123Lutrija (COCI19_lutrija)C++17
14 / 70
151 ms356 KiB
#include <bits/stdc++.h> using namespace std; #define int long long #define endl "\n" #define pb push_back #define ff first #define ss second #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() bool prime(int x){ if(x <= 1) return false; for(int i = 2; i * i <= x; i++){ if(x % i == 0) return false; } return true; } void solve(){ int a,b; cin >> a >> b; if(prime(abs(a-b))){ cout << "2\n" << a << ' ' << b << endl; return; } if(prime(a - 2) && prime(b - 2)){ cout << "3\n" << a << ' ' << 2 << ' ' << b << endl; return; } if(prime(a-2) && prime(abs(a-2 - b))){ cout << "3\n" << a << ' ' << a - 2 << ' ' << b << endl; } else if(prime(a+2) && prime(abs(a+2 - b))){ cout << "3\n" << a << ' ' << a + 2 << ' ' << b << endl; } else if(prime(b-2) && prime(abs(b-2 - a))){ cout << "3\n" << a << ' ' << b - 2 << ' ' << b << endl; } else if(prime(b+2) && prime(abs(b+2 - a))){ cout << "3\n" << a << ' ' << b + 2 << ' ' << b << endl; } else cout << -1 << endl; } signed main(){ ios::sync_with_stdio(0); cin.tie(0); int t = 1; // cin >> t; while(t--) solve(); return 0; }
#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...