Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <fstream>
- using namespace std;
- bool ciur[1200001];
- int i,j,n,k,v[201], mx,c,ct,nrn,x,p;
- unsigned int s;
- int main()
- {ifstream f("optime.in");
- ofstream g("optime.out");
- f>>c;
- n=1200000;
- ciur[1]=1;
- for(i=2;i*i<=n;i++)
- for(j=2;j<=n/i;j++) ciur[i*j]=1;
- if(c==1) {f>>k;
- nrn=2*k*k;
- i=11;
- while(ct<nrn) {if(ciur[i]==0 && i%100>=10) {ct++;
- if(ciur[i%100]==1) {x++;
- s=s+i%100;}
- }
- i=i+2;
- }
- g<<s;
- }
- else {f>>k>>x;
- nrn=2*k*k;
- i=11;
- while(ct<nrn) {if(ciur[i]==0 && i%100>=10) {ct++;
- if(ct%k!=0) {if(ciur[i%100]==0) v[ct%k]++;}
- else if(ciur[i%100]==0) v[k]++;
- }
- i=i+2;
- }
- s=0;
- for(i=1;i<=x;i++) s=s+v[i];
- mx=s; p=1;
- for(i=x+1;i<=k;i++) {s=s+v[i]-v[i-x];
- if(s>=mx) {mx=s;
- p=i-x+1;}
- }
- g<<p<<'\n'<<mx;}
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment