#include <bits/stdc++.h>
/*
author: aykhn
5/4/2023
*/
using namespace std;
typedef long long ll;
const int oo = INT_MAX;
const ll ooo = LONG_MAX;
const ll mod = 1e9 + 7;
#define OPT ios_base::sync_with_stdio(0); \
cin.tie(0); \
cout.tie(0)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define all(v) v.begin(), v.end()
#define mpr make_pair
#define pb push_back
#define ts to_string
#define fi first
#define se second
#define inf 0x3F3F3F3F
#define tos to_string
#define infll 0x3F3F3F3F3F3F3F3FLL
#define bpc __builtin_popcount
bool isPrime(ll a)
{
if (a <= 1) return false;
for (ll i = 2; i * i <= a; i++)
{
if (a % i == 0) return false;
}
return true;
}
int main()
{
ll a, b;
cin >> a >> b;
if (min(a, b) == 3 && max(a, b) == 7)
{
cout << 3 << endl;
cout << a << " 5 " << b << endl;
return 0;
}
if (isPrime(abs(a - b)))
{
cout << 2 << endl;
cout << a << " " << b << endl;
return 0;
}
if (min(a, b) != 2)
{
if (isPrime(a - 2) && isPrime(b - 2))
{
cout << 3 << endl;
cout << a << " " << 2 << " " << b << endl;
return 0;
}
cout << -1 << endl;
return 0;
}
if (isPrime(max(a, b) - 2) && isPrime(max(a, b) - 4))
{
cout << 3 << endl;
cout << a << " " << max(a, b) - 2 << " " << b << endl;
return 0;
}
if (isPrime(max(a, b) + 2))
{
cout << 3 << endl;
cout << a << " " << max(a, b) + 2 << " " << b << endl;
return 0;
}
cout << -1 << endl;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
0 ms |
300 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
300 KB |
Output is correct |
4 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
0 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
304 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |