Submission #493620

# Submission time Handle Problem Language Result Execution time Memory
493620 2021-12-12T11:49:06 Z inksamurai Lutrija (COCI19_lutrija) C++17
0 / 70
132 ms 460 KB
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) a.begin(),a.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define crep(i,x,n) for(int i=x;i<n;i++)
#define drep(i,n) for(int i=n-1;i>=0;i--)
#define vec(...) vector<__VA_ARGS__>
#define _3dDwnkq ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
using pii=pair<int,int>;
using vi=vector<int>;
 
bool prime(ll c){
	if(c==2) return true;
	for(ll j=2;j<=sqrt(c);j++){
		if(c%j==0){
			return false;
		}
	}
	return true;
}

int main(){
_3dDwnkq;
	ll a,b;
	cin>>a>>b;
	assert(min(a,b)>2);
	if(prime(a+b)){
		cout<<"3\n";
		cout<<a<<" "<<a+b<<" "<<b<<"\n";
		exit(0);
	}
	if(prime(abs(a-b))){
		cout<<"2\n";
		cout<<a<<" "<<b<<"\n";
		exit(0);
	}
	vec(ll) pans;
	if(a<b){
		while(a<b and prime(a)){
			pans.pb(a);
			a+=2;
		}
		if(a!=b) pans={};
		else pans.pb(b);
	}else{
		while(a>b and prime(a)){
			pans.pb(a);
			a-=2;
		}
		if(a!=b) pans={};
		else pans.pb(b);
	}
	if(sz(pans) and sz(pans)<=30){
		cout<<sz(pans)<<"\n";
		for(auto x : pans){
			cout<<x<<" ";
		}
		cout<<"\n";
	}else{
		cout<<"-1\n";
	}
//	
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 204 KB Output is correct
2 Incorrect 0 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 460 KB Execution killed with signal 6
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 132 ms 288 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 72 ms 288 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 92 ms 292 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 87 ms 300 KB Output isn't correct
2 Halted 0 ms 0 KB -