답안 #339015

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
339015 2020-12-24T11:28:18 Z A_D Lutrija (COCI19_lutrija) C++14
0 / 70
3 ms 2668 KB
#include <bits/stdc++.h>
#define ll long long
#define F first
#define S second
using namespace std;
const ll N=1e3+10;
const ll M=1e6+110;
vector<int> p;
bool b[M];
int sz;
bool ok(ll v)
{
    for(ll i=2;i*i<=v;i++){
        if(v%i==0)return 0;
    }
    return 1;
}
void sev()
{
    for(int i=2;i<=1e6;i++){
        if(b[i]==0){
            p.push_back(i);
            sz++;
            for(int j=i*i;j<=1e7;j+=i){
                b[j]=1;
            }
        }
    }
}
main()
{
    sev();
    ll a,b,q;
    q=1;
    while(q--){
        cin>>a>>b;
        if(ok(abs(a-b))){
            cout<<2<<endl;
            cout<<a<<" "<<b<<endl;
        }
        if(abs(a-b)%2==0){
            cout<<-1;
            return 0;
        }
        for(int i=0;i<min(2000,sz);i++){
            ll v=abs(a-p[i]);
            v+=abs(b-p[i]);
            if(ok(v)){
                cout<<3<<endl;
                cout<<a<<" "<<p[i]<<" "<<b<<endl;
                return 0;
            }
        }
    }
}







Compilation message

lutrija.cpp:30:6: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
   30 | main()
      |      ^
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 2668 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 2668 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 2668 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 2668 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 2668 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 2668 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 2668 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 2668 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 2668 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 3 ms 2668 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -