#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int MAX = 2e7 + 15;
const int INF = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
#define pb push_back
#define sz(x) (int) x.size()
#define fr first
#define sc second
#define mp make_pair
#define all(x) x.begin(), x.end()
#define dbg(x) cerr << #x << ": " << "[ " << x << " ]\n"
ll l, r, ind[MAX];
bool notPrime[MAX], inv, pos;
vector<ll> primes, ans;
void Crivo(ll n){
notPrime[1] = true;
for(int i = 2; i <= n; i++){
if(notPrime[i]) continue;
primes.push_back(i);
ind[i] = sz(primes) - 1;
for(int j = 2; i * j <= n; j++)
notPrime[i * j] = true;
}
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
Crivo(1050);
cin >> l >> r;
if(l == r){
cout << 1 << '\n' << l << '\n';
}else if(!notPrime[abs(l - r)]){
cout << 2 << '\n' << l << ' ' << r << '\n';
}else{
for(int i = 0; i < sz(primes); i++){
int p = primes[i];
if(!notPrime[abs(p - l)] && !notPrime[abs(p - r)]){
cout << 3 << '\n' << l << ' ' << p << ' ' << r << '\n';
return 0;
}
}
cout << -1 << '\n';
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
352 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
340 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
4 ms |
424 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
3 ms |
468 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
5 ms |
484 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
5 ms |
424 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |