Submission #871628

#TimeUsernameProblemLanguageResultExecution timeMemory
871628vjudge1Lutrija (COCI19_lutrija)C++11
7 / 70
0 ms600 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; vector <int> ans; int isPrime(ll a) { if(a < 2) return 0; if(a <= 3) return 1; for(int i = 2; i * i <= a; i++) { if (a % i == 0) return 0; } return 1; } void finish() { cout << -1; exit(0); } int main() { ll a, b; cin >> a >> b; if(a % 2 == 0 && b % 2 == 0) finish(); if(isPrime(abs(a-b))) { cout << "2\n" << a << " " << b << "\n"; return 0; } if(a % 2 && b % 2) { if(isPrime(a-2) && isPrime (b-2)) {cout << "5\n" << a << " 2 5 2 " << b << "\n"; return 0;} else finish(); } if(a % 2) { if(isPrime(a + 2)) {cout << "3\n" << a << " " << a+2 << " " << b << "\n"; return 0;} else if(isPrime(a-2)) {cout << "4\n " << a << " 2 " << a << " 2" << "\n"; return 0;} else finish(); } if(b % 2) { if(isPrime(b + 2)) {cout << "3\n" << a << " " << b+2 << " " << b << "\n"; return 0;} else if(isPrime(b-2)) {cout << "4\n " << "2 " << b << " 2 " << b << "\n"; return 0;} else finish(); } 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...