Submission #250615

# Submission time Handle Problem Language Result Execution time Memory
250615 2020-07-18T14:12:59 Z REALITYNB Lutrija (COCI19_lutrija) C++14
0 / 70
2000 ms 384 KB
#include <bits/stdc++.h> 
bool check(int i){
		bool prime= 1 ; 
		for(int j=2;j*j<=i;j++){
			if(i%j==0){
				prime = 0; 
			}
		}
		return prime ;  
}
using namespace std; 
int main(){
	int a , b ; 
	cin>>a>>b ; 
	if(a>2&&b>2&&abs(b-a)==2){
		cout << 2 << endl << a << " "<< b  ; 
		return 0  ; 
	}
	if(a>2&&b>2&&abs(b-a)/2>29){
		cout << -1 ; 
		return 0 ; 
	}
	if(a>2&&b>2){
		int flg = 0 ; 
		if(a>b){
			swap(a,b) ; 
			flg = 1 ; 
		}
		vector<int> ans ;
		ans.push_back(a) ;  
		while(a!=b){
			a+=2 ; 
			ans.push_back(a) ; 
			if(check(a)==0){
				cout << -1 ; 
				return 0 ; 
			}
		}
		reverse(ans.begin(),ans.end()) ; 
		cout <<  abs(b-a)/2+1 << endl  ; 
		for(int& x :ans) cout << x << " "  ; 
		return 0 ; 
	}
	if(check(abs(a-b))){
		cout << 2 << endl ; 
		cout << a  <<  " " << b  ; 
		return 0  ; 
	}
	if(check(max(a,b)+2)){
		cout << 3 << endl ; 
		cout << a <<  " " << b+2 << " " <<  b ; 
		return 0 ;                
	}
	cout << -1 ; 
	return  0 ; 
}

Compilation message

lutrija.cpp: In function 'int main()':
lutrija.cpp:24:7: warning: variable 'flg' set but not used [-Wunused-but-set-variable]
   int flg = 0 ; 
       ^~~
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB Output is correct
2 Incorrect 0 ms 256 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 384 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 256 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2067 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2080 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2081 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 2076 ms 256 KB Time limit exceeded
2 Halted 0 ms 0 KB -