# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
335237 | CaroLinda | Lutrija (COCI19_lutrija) | C++14 | 96 ms | 452 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#define sz(x) (int)(x.size() )
#define ll long long
using namespace std ;
bool isPrime(ll x)
{
if(x <= 1LL ) return false ;
for(ll i = 2 ; i*i <= x ; i++ )
if( x%i == 0 ) return false ;
return true ;
}
void giveAns(vector<int> &ans )
{
if(sz(ans) == 1 ) printf("%d\n", ans[0] ) ;
else
{
printf("%d\n", sz(ans) ) ;
for(auto e : ans ) printf("%d ", e ) ;
printf("\n") ;
}
exit(0) ;
}
void solve( int B , vector<int> &ans )
{
if(B == 2)
{
ans.push_back(2) ;
ans.push_back(5) ;
ans.push_back(2) ;
giveAns(ans) ;
}
if( isPrime(B-2) )
{
ans.push_back( 2 ) ;
ans.push_back( B ) ;
giveAns(ans) ;
}
if( isPrime(B+2) )
{
ans.push_back(2) ;
ans.push_back(B+2) ;
ans.push_back(B) ;
giveAns(ans) ;
}
ans = {-1} ;
giveAns(ans) ;
}
int main()
{
ll A , B ;
scanf("%lld %lld", &A, &B) ;
vector<int> ans ;
if(A == 3 )
{
ans.push_back(3) ;
A = 5 ;
}
if(A == 5 )
{
ans.push_back(5) ;
A = 7 ;
}
if( A == 2 ) solve( B, ans) ;
if( isPrime(A-2) )
{
ans.push_back(A) ;
solve(B, ans) ;
}
if( isPrime(A+2) )
{
ans.push_back(A) ;
ans.push_back(A+2) ;
solve(B, ans) ;
}
ans = {-1} ;
giveAns(ans) ;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |