Submission #1089555

#TimeUsernameProblemLanguageResultExecution timeMemory
1089555sangerafLutrija (COCI19_lutrija)C++17
70 / 70
41 ms604 KiB
#include <bits/stdc++.h> using namespace std; bool isPrime(long long x){ if(x==1) return 0; for(long long i=2; i*i<=x; i++){ if(x%i==0) return 0; } return 1; } int main() { long long a, b; cin >> a >> b; if(max(a-b, b-a) == 2){ cout << 2 << endl << a << " " << b << endl; return 0; } vector<long long> ans; if(a>2){ if(isPrime(a-2)){ ans.push_back(a); }else if(isPrime(a+2)){ ans.push_back(a); ans.push_back(a+2); }else{ cout << -1 << endl; return 0; } } ans.push_back(2); if(b>2){ if(isPrime(b-2)){ ans.push_back(b); }else if(isPrime(b+2)){ ans.push_back(b+2); ans.push_back(b); }else{ cout << -1 << endl; return 0; } } cout << ans.size() << endl; for(int i=0; i<ans.size(); i++){ cout << ans[i] << " "; } cout << endl; }

Compilation message (stderr)

lutrija.cpp: In function 'int main()':
lutrija.cpp:43:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |  for(int i=0; i<ans.size(); 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...