답안 #335238

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
335238 2020-12-11T16:45:06 Z CaroLinda Lutrija (COCI19_lutrija) C++14
70 / 70
192 ms 492 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<ll> &ans )
{
	if(sz(ans) == 1 ) printf("-1\n" ) ;
	else
	{
		printf("%d\n", sz(ans) ) ;
		for(auto e : ans ) printf("%lld ", e ) ;
		printf("\n") ;
	}
	exit(0) ;
}

void solve( ll B , vector<ll> &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<ll> 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) ;
      |  ~~~~~^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 0 ms 364 KB Output is correct
4 Correct 0 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 288 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
4 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 0 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 160 ms 364 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 192 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 155 ms 492 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 139 ms 364 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 172 ms 368 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 128 ms 492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 126 ms 492 KB Output is correct
2 Correct 1 ms 364 KB Output is correct
3 Correct 45 ms 364 KB Output is correct