답안 #486019

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
486019 2021-11-10T07:19:56 Z tato Lutrija (COCI19_lutrija) C++14
70 / 70
153 ms 288 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll m=1e15;
bool check(ll a)
{
	ll x=sqrt(a);
	
	for(ll k=2; k<=x; k++)
		if(a%k==0)
			return false;
			
	return true;
	
	
	
}

int main()
{
	ll  a,b;
	
	cin>>a>>b;
		if(check(a-2) and check(b-2) and a>3 and b>3)
			{
				cout<<3<<'\n';
				cout<<a<<' '<<2<<' '<<b;
				return 0;
			}
			if(abs(a-b)==2)
		{
			cout<<2<<'\n';
			cout<<a<<' '<<b;
			return 0;
		}
	
		
	
	if(a==2)
		{
			if(check(b+2))
				{
					cout<<3<<'\n';
					cout<<a<<' '<<b+2<<' '<<b;
					return 0;
				}
			
			if(b>6 and check(b-2) and check(b-4))
				{
					cout<<3<<'\n';
					cout<<a<<' '<<b-2<<' '<<b;
					return 0;
				}
	}
	if(b==2)
		{
		
		if(check(a+2))
			{
			cout<<3<<'\n';
			cout<<a<<' '<<a+2<<' '<<b;
			return 0;
			}	
			
			if(a>6 and check(a-2) and check(a-4))
				{
					cout<<3<<'\n';
					cout<<a<<' '<<a-2<<' '<<b;
					return 0;
				}			
		}
	ll mn=min(a,b),mx=max(a,b);
	
	if(check(a+2))
		if(check(b+2))
		{
			cout<<5<<'\n';
			cout<<a<<' '<<a+2<<' '<<2<<' '<<b+2<<' '<<b;
			return 0;
		}
		else
			{
				if(b>6 and check(b-2) and  check(b-4))
					{
						cout<<5<<'\n';
						cout<<a<<' '<<a+2<<' '<<2<<' '<<b-2<<' '<<b;
						return 0;
					}
				
			}
	else
		if(check(b+2))	
			{
				if(a>6 and check(a-2) and check(a-4))
					{
						cout<<5<<' ';
						cout<<a<<' '<<a-2<<' '<<2<<' '<<b+2<<' '<<b;
						return 0;
					}
			}
		
	

	
cout<<-1;


	return 0;
}

Compilation message

lutrija.cpp: In function 'int main()':
lutrija.cpp:72:5: warning: unused variable 'mn' [-Wunused-variable]
   72 |  ll mn=min(a,b),mx=max(a,b);
      |     ^~
lutrija.cpp:72:17: warning: unused variable 'mx' [-Wunused-variable]
   72 |  ll mn=min(a,b),mx=max(a,b);
      |                 ^~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
4 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 288 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 140 ms 264 KB Output is correct
2 Correct 83 ms 276 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 135 ms 268 KB Output is correct
2 Correct 86 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 153 ms 268 KB Output is correct
2 Correct 84 ms 204 KB Output is correct
3 Correct 0 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 109 ms 204 KB Output is correct
2 Correct 60 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct