답안 #485961

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
485961 2021-11-09T20:44:12 Z tato Lutrija (COCI19_lutrija) C++14
7 / 70
1 ms 204 KB
#include <bits/stdc++.h>
#define ll long long
using namespace std;

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(abs(a-b)==1)
			{
				if(a>b)
					{
						if(check(b+3))
							if(check(a+2))
								{
									cout<<2<<'\n';
									cout<<a<<' '<<a+2<<' '<<b;
									return 0;
								}
						if(a>4)
							if(check(b-2))
								if(check(a-3))
									{
											cout<<2<<'\n';
											cout<<a<<' '<<a-3<<' '<<b;
											return 0;
									}		
								
					}
				else
					{
						
						if(check(a+3))
							if(check(b+2))
								{
									cout<<2<<'\n';
									cout<<a<<' '<<b+2<<' '<<b;
									return 0;
								}
						if(b>4)
							if(check(a-2))
								if(check(b-3))
									{
											cout<<2<<'\n';
											cout<<a<<' '<<b-3<<' '<<b;
											return 0;
									}		
								
					}
				
				cout<<-1;
				return 0;
			}
	if(a==2)
		{
			if(check(b+2))
			{
			cout<<3<<'\n';
			cout<<a<<' '<<b+2<<' '<<b;
			
			return 0;
			}
			else
				if(check(b-2) and (b-2)>1)
					{
						cout<<3<<'\n';
						cout<<a<<' '<<b-2<<' '<<b;
						return 0;
					}
				else
					{
						cout<<-1;
						return 0;
					}
	}
	if(b==2)
		{
			if(check(a+2))
			{
			cout<<3<<'\n';
			cout<<a<<' '<<a+2<<' '<<b;
			
			return 0;
			}
			else
				if(check(a-2) and (a-2)>1)
					{
						cout<<3<<'\n';
						cout<<a<<' '<<a-2<<' '<<b;
					}
					else
						{
							cout<<-1;
							return 0;
						}
	}
	if(abs(a-b)==2)
		{
			cout<<2<<'\n';
			cout<<a<<' '<<b;
			return 0;
		}
		
		if(check(a-2) and check(b-2))
			{
				cout<<3<<'\n';
				cout<<a<<' '<<2<<' '<<b;
				return 0;
			}
	if(abs(a-b)>62)
		{
			cout<<-1;
			return 0;
		}
		vector <ll> v;
		
		ll mn=min(a,b),mx=max(a,b);
	for(ll i=mn; i<=mn+60; i+=2)
		{
			if(!check(i))
				{
					cout<<-1;
					return 0;
				}
			else
				v.push_back(i);
		}
		if(v.size()<=2)
			{
				cout<<-1;
				return 0;
			}
			
	cout<<v.size()<<'\n';
	
	for(int k=0; k<v.size(); k++)
		cout<<v[k]<<' ';

	return 0;
}

Compilation message

lutrija.cpp: In function 'int main()':
lutrija.cpp:153:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  153 |  for(int k=0; k<v.size(); k++)
      |               ~^~~~~~~~~
lutrija.cpp:134:18: warning: unused variable 'mx' [-Wunused-variable]
  134 |   ll mn=min(a,b),mx=max(a,b);
      |                  ^~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -