Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- #define ll long long
- #define pub(a, x) (a).push_back(x)
- using namespace std;
- void update(ll* n){
- *n=(*n<4)?((*n==2)?3:5):((*n-1)%6)?(*n+2):(*n+4);
- }
- bool cprm(ll n){
- if(n==2||n==3) return 1;
- if(n%2==0||n%3==0||n<2) return 0;
- for(ll i=5; i<=sqrt(n); update(&i)) if(n%i==0) return 0;
- return 1;
- }
- vector<ll> a={0}, b={0};
- ll inp, n=1;
- int main(){
- freopen("NUMBER.inp", "r", stdin);
- freopen("NUMBER.out", "w", stdout);
- ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
- cin>>inp;
- pub(b, cprm(inp));
- while(cin>>inp){
- n++;
- if(cprm(inp)){
- pub(b, 1);
- if(b[n-2]){
- cout<<n-1;
- return 0;
- }
- }
- else pub(b, 0);
- }
- cout<<0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement