# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
711097 |
2023-03-16T08:34:48 Z |
dozer |
Lutrija (COCI19_lutrija) |
C++14 |
|
323 ms |
332 KB |
#include <bits/stdc++.h>
using namespace std;
#define sp " "
#define endl "\n";
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define pb push_back
#define pii pair<int, int>
#define st first
#define nd second
#define N 200005
#define int long long
const int modulo = 1e9 + 7;
int dp[1005][1005];
bool is_prime(int num)
{
num = abs(num);
if (num < 2) return 0;
for (int i = 2; i * i <= num; i++)
if (num % i == 0) return 0;
return 1;
}
vector<int> ans;
void solve(int a, int b)
{
if (a == b)
{
ans.pb(a);
return;
}
if (is_prime(b - a))
{
ans.pb(a);
solve(b, b);
}
else if (is_prime(a - 2))
{
ans.pb(a);
solve(2, b);
}
else if (is_prime(a + 2))
{
ans.pb(a);
solve(a + 2, b);
}
else if (is_prime(b - 2))
{
solve(a, 2);
ans.pb(b);
}
else if (is_prime(b + 2))
{
solve(a, b + 2);
ans.pb(b);
}
}
int32_t main()
{
fastio();
int a, b;
cin>>a>>b;
solve(a, b);
if (ans.size() > 30) return 1;
if (ans.back() == b)
{
cout<<ans.size()<<endl;
for (auto i : ans) cout<<i<<sp;
cout<<endl;
}
else cout<<-1<<endl;
cerr << "time taken : " << (float)clock() / CLOCKS_PER_SEC << " seconds\n";
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
332 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
328 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
324 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
324 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
Output is correct |
2 |
Incorrect |
1 ms |
212 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
298 ms |
304 KB |
Output is correct |
2 |
Incorrect |
174 ms |
304 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
279 ms |
304 KB |
Output is correct |
2 |
Incorrect |
172 ms |
316 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
323 ms |
212 KB |
Output is correct |
2 |
Incorrect |
178 ms |
308 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
228 ms |
304 KB |
Output is correct |
2 |
Incorrect |
129 ms |
312 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |