Submission #335237

# Submission time Handle Problem Language Result Execution time Memory
335237 2020-12-11T16:43:35 Z CaroLinda Lutrija (COCI19_lutrija) C++14
42 / 70
96 ms 452 KB
#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

lutrija.cpp: In function 'int main()':
lutrija.cpp:66:7: warning: ignoring return value of 'int scanf(const char*, ...)', declared with attribute warn_unused_result [-Wunused-result]
   66 |  scanf("%lld %lld", &A, &B) ;
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 372 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 73 ms 364 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 79 ms 452 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 95 ms 372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 96 ms 372 KB Output isn't correct
2 Halted 0 ms 0 KB -