Submission #250611

#TimeUsernameProblemLanguageResultExecution timeMemory
250611REALITYNBDžumbus (COCI19_dzumbus)C++14
0 / 110
1 ms256 KiB
#include <bits/stdc++.h> using namespace std ; bool check(int i){ bool prime= 1 ; for(int j=2;j*j<=i;j++){ if(i%j==0){ prime = 0; } } return prime ; } int main(){ int a , b ; cin>>a>>b ; vector<int> p ; vector<int> isp(1001) ; for(int i=2;i<=1000;i++){ bool prime= check(i) ; isp[i] = prime ; if(prime) p.push_back(i) ; } if(isp[abs(a-b)]){ cout << 2 << endl ; cout << a << " " << b ; return 0 ; } for(int i=1;i<1001;i++){ if(isp[i]==0) continue ; int x = i ; int dif = abs(x-a) , diff = abs(x-b) ; if(isp[dif]&&isp[diff]){ cout << 3 << endl ; cout << a << " "<< x << " "<< b ; return 0 ; } } cout << -1 ; 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...