답안 #229217

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
229217 2020-05-03T21:02:39 Z VEGAnn Lutrija (COCI19_lutrija) C++14
70 / 70
177 ms 416 KB
#include <bits/stdc++.h>
#define all(x) x.begin(),x.end()
#define MP make_pair
#define PB push_back
#define ft first
#define sd second
#define pii pair<int, int>
#define sz(x) ((int)x.size())
using namespace std;
const int N = 10010;
const int oo = 2e9;
typedef long long ll;
vector<ll> vc;
bool t1, t2;
ll a, b;

void BAD() { cout << -1; exit(0); }

bool prim(ll x){
	if (x == 1) return 0;
	for (ll i = 2; i * i <= x; i++)
		if (x % i == 0)
			return 0;
	
	return 1;
}

void ANS(){
	cout << sz(vc) << '\n';
	
	for (ll x : vc)
		cout << x << " ";
		
	exit(0);
}

int main(){
	
	ios_base::sync_with_stdio(0); cin.tie(0);
	
//	freopen("in.txt","r",stdin);

	cin >> a >> b;
	
	if (prim(abs(a - b))){
		cout << "2\n" << a << " " << b;
		return 0;
	}
	
	if (a == 2){
		
		if (prim(b - 2))
			t2 = 0;
		else if (prim(b + 2))
			t2 = 1;
		else BAD();
		
		vc.PB(2);
		if (t2)
			vc.PB(b + 2);
		vc.PB(b);
		
		ANS();
		
		return 0;
	}
	
	if (b == 2){
			
		if (prim(a - 2))
			t2 = 0;
		else if (prim(a + 2))
			t2 = 1;
		else BAD();
		
		vc.PB(a);
		if (t2)
			vc.PB(a + 2);
		vc.PB(2);
		
		ANS();
			
		return 0;
	}
	
	if (prim(a - 2))
		t1 = 0;
	else if (prim(a + 2))
		t1 = 1; 
	else BAD();
	
	if (prim(b - 2))
		t2 = 0;
	else if (prim(b + 2))
		t2 = 1; 
	else BAD();
	
	vc.clear();
	
	if (t1){
		vc.PB(a);
		vc.PB(a + 2);
	} else vc.PB(a);
	
	vc.PB(2);
	
	if (t2){
		vc.PB(b + 2);
	}
	vc.PB(b);
	
	ANS();
	
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 169 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 161 ms 416 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 177 ms 388 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 132 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct