Submission #234359

# Submission time Handle Problem Language Result Execution time Memory
234359 2020-05-24T04:47:33 Z super_j6 Lutrija (COCI19_lutrija) C++14
70 / 70
349 ms 512 KB
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
#define endl '\n'
#define ll long long
#define pi pair<int, int>
#define f first
#define s second
 
ll a, b;
 
bool ptest(ll x){
    if(x <= 1) return !x;
    for(ll i = 2; i * i <= x; i++){
        if(x % i == 0) return 0;
    }
    return 1;
}
 
ll val(ll x){
    for(int i = -2; i <= 2; i += 2){
        if(ptest(x + i - 2) && ptest(x + i)) return x + i;
    }
    return 0;
}
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> a >> b;
	
	if(ptest(abs(a - b))){
	    cout << 2 << endl;
	    cout << a << " " << b << endl;
	}else{
	    ll x = val(a), y = val(b);
	    if(!x || !y){
	        cout << -1 << endl;
	    }else{
    	    cout << 1 + (x != a) + (x != 2) + (y != 2) + (y != b) << endl;
    	    cout << a << " ";
    	    if(x != a) cout << x << " ";
    	    if(x != 2) cout << 2 << " ";
    	    if(y != b && y != 2) cout << y << " ";
    	    cout << b << endl;
	    }
	}
 
	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 512 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 432 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 384 KB Output is correct
2 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 322 ms 504 KB Output is correct
2 Correct 331 ms 504 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 314 ms 376 KB Output is correct
2 Correct 206 ms 412 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 349 ms 504 KB Output is correct
2 Correct 254 ms 384 KB Output is correct
3 Correct 4 ms 384 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 255 ms 376 KB Output is correct
2 Correct 177 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct