Submission #205148

# Submission time Handle Problem Language Result Execution time Memory
205148 2020-02-28T07:42:30 Z mraron Lutrija (COCI19_lutrija) C++14
14 / 70
168 ms 504 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(a-2) && ip(b-2)) {
			ans={a,2,b};
		}else {
			vector<ll> ans2;
			for(ll i=a;i<=b;i+=2) {
				if(ip(i)) ans2.push_back(i); else break ;
			}
			if(ans2.back()==b) ans=ans2;
		}
	}
	
	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 248 KB Output is correct
2 Correct 5 ms 256 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 256 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 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 4 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 300 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 154 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 166 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 168 ms 504 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 68 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -