-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path50.cpp
More file actions
48 lines (41 loc) · 996 Bytes
/
Copy path50.cpp
File metadata and controls
48 lines (41 loc) · 996 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
#include<iostream>
using namespace std;
int b[100001];
int j=3;
int max1=0;
int isprime(int x)
{
for(int i=0;i<j;i++)
if(b[i]==x)
return 1;
return 0;
}
int main()
{b[0]=2;b[1]=3;b[2]=5;
for( int k=7;k<1000000;k+=2)
{int l=0;
for(int i=0;i<j;i++)
if(k%b[i]==0)
{l=1;break;}
if(!l)
{b[j]=k;
j++;
// cout<<b[2]<<"\t"<<k<<endl;
}
}
for(int i=0;i<10;i++)
{ int sum=0;
for(int z=i;z<j&&sum<1000000;z++)
{sum+=b[z];
if(isprime(sum))
{
//cout<<i<<"\t"<<z<<"\t"<<b[i]<<"\t"<<b[z]<<"\t"<<sum<<endl;
if(max1<(z-i)&&sum<1000000)
{max1=z-i;cout<<i<<"\t"<<z<<"\t"<<b[i]<<"\t"<<b[z]<<"\t"<<sum<<endl;}
}
}
}
cout<<j<<"\t"<<b[j-1];
system("pause");
return 0;
}