답안 #660756

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
660756 2022-11-23T07:08:43 Z Koful123 Lutrija (COCI19_lutrija) C++17
0 / 70
96 ms 296 KB
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define endl "\n"
#define pb push_back
#define ff first
#define ss second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

bool prime(int x){
	if(x <= 1) return false;
	for(int i = 2; i * i <= x; i++){
		if(x % i == 0) return false;
	}
	return true;
}

void solve(){

	int a,b;
	cin >> a >> b;

	if(prime(abs(a-b))){
		cout << "2\n" << a << ' ' << b << endl;
		return;
	}

	if(a == 2){
		vector<int> v(4),num(4);
		for(int i = 0; i < 4; i++){
			num[i] = b + (i - 2 + (i >= 2)) * 2;
			v[i] = prime(num[i]);
		}
		if(v[0] && v[1] && prime(abs(num[0] - a))){
			cout << "4\n" << a << ' ' << num[0] << ' ' << num[1] << ' ' << b << endl;
		}
		else if(v[1] && prime(abs(num[1] - a))){
			cout << "3\n" << a << ' ' << num[1] << ' ' << b << endl;
		}
		else if(v[2] && v[3] && prime(abs(num[3] - a))){
			cout << "4\n" << a << ' ' << num[3] << ' ' << num[2] << ' ' << b << endl; 
	 	}
		else if(v[2] && prime(abs(num[2] - a))){
			cout << "3\n" << a << ' ' << num[2] << ' ' << b << endl;
		}
	}
	else if(b == 2){
		vector<int> v(4),num(4);
		for(int i = 0; i < 4; i++){
			num[i] = a + (i - 2 + (i >= 2)) * 2;
			v[i] = prime(num[i]);
		}
		if(v[0] && v[1] && prime(abs(num[0] - b))){
			cout << "4\n" << a << ' ' << num[1] << ' ' << num[0] << ' ' << b << endl;
		}
		else if(v[1] && prime(abs(num[1] - b))){
			cout << "3\n" << a << ' ' << num[1] << ' ' << b << endl;
		}
		else if(v[2] && v[3] && prime(abs(num[3] - b))){
			cout << "4\n" << a << ' ' << num[2] << ' ' << num[3] << ' ' << b << endl; 
	 	}
		else if(v[2] && prime(abs(num[2] - a))){
			cout << "3\n" << a << ' ' << num[2] << ' ' << b << endl;
		}
	}
	else{
		if(prime(a + 2) && b - a == 4){
			cout << "3\n" << a << ' ' << a + 2 << ' ' << 4 << endl;
		}
		else cout << -1 << endl;
	}

}
 
signed main(){	
 		
	ios::sync_with_stdio(0);
	cin.tie(0);
 
	int t = 1;
//	cin >> t;
 
	while(t--)
		solve();
 
	return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Incorrect 0 ms 212 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 64 ms 296 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 69 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 96 ms 296 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 91 ms 296 KB Output isn't correct
2 Halted 0 ms 0 KB -