Submission #704770

# Submission time Handle Problem Language Result Execution time Memory
704770 2023-03-03T01:40:06 Z willychan Lutrija (COCI19_lutrija) C++14
35 / 70
162 ms 300 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include<bits/extc++.h>
//__gnu_pbds

bool isprime(ll p){
	for(ll i=2;i<=sqrt(p);i++){
		if(p%i==0) return 0;
	}
	return 1;
}

bool twin(ll G){
	if(G%6==5){
		return (isprime(G+2))	;
	}else if(G%6==1){
		return isprime(G-2);
	}
	return 0;
}


int main(){
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	ll A,B;cin>>A>>B;
	if((twin(A)||A==2) && (twin(B)||B==2)){
		if(A==2){
			if(B%6==5){
				cout<<3<<"\n";
				cout<<A<<" "<<B+2<<" "<<B<<"\n";
				return 0;
			}else{
				cout<<2<<"\n";
				cout<<A<<" "<<B<<"\n";
				return 0;
			}
		}
		if(B==2){
			if(A%6==5){
				cout<<3<<"\n";
				cout<<B<<" "<<A+2<<" "<<A<<"\n";
				return 0;
			}else{
				cout<<2<<"\n";
				cout<<B<<" "<<A<<"\n";
				return 0;
			}
		}
		if(abs(A-B)==2){
			cout<<2<<"\n";
			cout<<A<<" "<<B<<"\n";
			return 0;
		}
		vector<int> ans;
		ans.push_back(A);
		if(A%6==5){
			ans.push_back(A+2);
		}
		ans.push_back(2);
		if(B%6==5){
			ans.push_back(B+2);
		}
		ans.push_back(B);
		cout<<ans.size()<<"\n";
		for(auto i : ans) cout<<i<<" ";
		cout<<"\n";
	}else{
		cout<<-1<<"\n";
	}
	return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 148 ms 296 KB Integer parameter [name=arr[4]] equals to -2039078211, violates the range [1, 1000000000000000]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 139 ms 300 KB Integer parameter [name=arr[1]] equals to -2145466189, violates the range [1, 1000000000000000]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 162 ms 292 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 112 ms 296 KB Integer parameter [name=arr[4]] equals to -2070243847, violates the range [1, 1000000000000000]
2 Halted 0 ms 0 KB -