| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1370215 | eyadooz | Lutrija (COCI19_lutrija) | C++20 | 111 ms | 432 KiB |
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int) (x).size()
#define endl '\n'
#define int long long
bool prime(int x) {
for(int i=2;i*i<=x;i++) {
if(x%i==0) return 0;
}
return 1;
}
main()
{
cin.tie(0) -> sync_with_stdio(0);
int a, b;
cin >> a >> b;
bool swp=0;
int orgb=b, oa, ob;
if(a>b) {swap(a, b);swp=1;}
oa=a, ob=b;
if(a==2) {
vector<int> ans;
if(prime(b-a)) {
ans.pb(a);
ans.pb(b);
}
else if(prime(b+2)) {
ans.pb(a);
ans.pb(b+2);
ans.pb(b);
}
else if(b-2>1&&prime(b-2)&&prime(abs(b-4))) {
ans.pb(a);
ans.pb(b-2);
ans.pb(b);
}
if(swp) reverse(all(ans));
if(sz(ans)==0) {cout << -1 << endl;return 0;}
cout << sz(ans) << endl;
for(auto i : ans) cout << i << " ";
}
else {
vector<int> ans;
bool valid=1;
ans.pb(a);
while(a<b&&sz(ans)<=30) {
a+=2;
if(!prime(a)) valid=0;
ans.pb(a);
}
if(swp) reverse(all(ans));
if(ans.back()!=orgb||!valid||sz(ans)>30) {
ans.clear();
a=oa, b=ob;
ans.pb(a);
if(!prime(abs(a-2))) {cout << -1 << endl;return 0;}
a=2;
if(prime(b-a)) {
ans.pb(a);
ans.pb(b);
}
else if(prime(b+2)) {
ans.pb(a);
ans.pb(b+2);
ans.pb(b);
}
else if(b-2>1&&prime(b-2)&&prime(abs(b-4))) {
ans.pb(a);
ans.pb(b-2);
ans.pb(b);
}
if(swp) reverse(all(ans));
if(sz(ans)==0) {cout << -1 << endl;return 0;}
cout << sz(ans) << endl;
for(auto i : ans) cout << i << " ";
return 0;
}
cout << sz(ans) << endl;
for(auto i : ans) cout << i << " ";
}
}
Compilation message (stderr)
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Result | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
