Submission #205336

# Submission time Handle Problem Language Result Execution time Memory
205336 2020-02-28T15:17:23 Z mraron Lutrija (COCI19_lutrija) C++14
14 / 70
181 ms 376 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool ip(ll x) {
	if(x==1) return false;
	for(ll i=2;i*i<=x;++i) {
		if(x%i==0) return false;
	}
	return true;
}
int main() {
	ll a,b;
	cin>>a>>b;
	bool rev=false;
	if(a>b) {
		swap(a,b);
		rev=true;
	}
	vector<ll> ans={-1};
	if(a==2) {
		if(ip(b-2)) {
			ans={a,b-2,b};
		}else if(ip(b+2)) {
			ans={a,b+2,b};
		}else if(ip(b-a)) {
			ans={a,b};
		}
	}else {
		if(ip(a-2) && ip(b-2)) {
			ans={a,2,b};
		}else if(ip(b-a)) {
			ans={a,b};
		}else if(ip(a+2) && ip(b-(a+2))) {
			ans={a,a+2,b};
		}else if(ip(b-2) && ip((b-2)-a)) {
			ans={a,b-2,b};
		}else if(ip(a-2) && ip(b-(a-2))) {
			ans={a,a-2,b};
		}else if(ip(b+2) && ip(b+2-(a))) {
			ans={a,b+2,b};
		}else if(ip((b+2)-(a-2)) && ip(b+2) && ip(a-2)) {
			ans={a,a-2,b+2,b};
		}else if(ip((b-2)-(a-2)) && ip(b-2) && ip(a-2)) {
			ans={a,a-2,b-2,b};
		}else if(ip((b-2)-(a+2)) && ip(b-2) && ip(a+2)) {
			ans={a,a+2,b-2,b};
		}else if(ip((b+2)-(a+2)) && ip(b+2) && ip(a+2)) {
			ans={a,a+2,b+2,b};
		}
	}
	
	if(rev) reverse(ans.begin(), ans.end());
	if(ans.size()>1) cout<<ans.size()<<"\n";
	for(auto i:ans) cout<<i<<" ";
	cout<<"\n";
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 5 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB Output is correct
2 Correct 5 ms 376 KB Output is correct
3 Correct 5 ms 256 KB Output is correct
4 Correct 6 ms 256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 170 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 164 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 181 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 134 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -