# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
203684 |
2020-02-21T20:03:50 Z |
grt |
Lutrija (COCI19_lutrija) |
C++17 |
|
5 ms |
420 KB |
#include <bits/stdc++.h>
#define PB push_back
#define ST first
#define ND second
#define _ ios_base::sync_with_stdio(0); cin.tie(0);
//mt19937 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
using namespace std;
using ll = long long;
using pi = pair<int,int>;
using vi = vector<int>;
ll a,b,B;
bool rev;
bool prime(ll x) {
if(x==1) return 0;
for(ll i=2; i*i<=x; i++) {
if(x%i==0) return 0;
}
return 1;
}
int main() {_
cin>>a>>b;
if(a>b) {
swap(a,b);
rev = 1;
}
B = b;
bool ok;
vector<ll>ans;
ans.PB(b);
for(int step = 0; step<30; step++) {
if(prime(b-a)) {
ans.PB(a);
ok = 1;
break;
}
ans.PB(b-2);
if(!prime(b-2)) break;
b-=2;
if(a==b) {
ok = 1;
break;
}
if((int)ans.size()==30) break;
}
if(!ok) {
ans.clear();
ans.PB(B);
b = B;
for(int step = 0; step<30; step++) {
if(prime(b-a)) {
ans.PB(a);
ok = 1;
break;
}
ans.PB(b+2);
if(!prime(b+2)) break;
b+=2;
if(a==b) {
ok = 1;
break;
}
if((int)ans.size()==30) break;
}
}
if(!ok) cout<<"-1";
else {
cout<<(int)ans.size()<<"\n";
if(!rev) reverse(ans.begin(),ans.end());
for(auto x:ans) cout<<x<<" ";
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
376 KB |
Output is correct |
2 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
384 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
420 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
5 ms |
376 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |