-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path27.cpp
More file actions
72 lines (59 loc) · 918 Bytes
/
Copy path27.cpp
File metadata and controls
72 lines (59 loc) · 918 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
#include<iostream>
#include<fstream>
using namespace std;
int j=3;
int b[10003];
int ans=0,pr=0;
int isprime(int x)
{
if(x<=1)
return 0;
for(int i=0;i<10003;i++)
if(b[i]==x)
return 1;
return 0;
}
void check(int p,int k)
{int i=0;
for(i=0;isprime(i*(i+p)+k);i++);
if(ans<i)
{ans=i;pr=p*k;
cout<<p<<"\t"<<k<<endl;}
for(i=0;isprime(i*(i-p)+k);i++);
if(ans<i)
{ans=i;pr=-1*p*k;
cout<<p<<"\t"<<k<<endl;}
for(i=0;isprime(i*(i+p)-k);i++);
if(ans<i)
{ans=i;pr=-1*p*k;
cout<<p<<"\t"<<k<<endl;}
for(i=0;isprime(i*(i-p)-k);i++);
if(ans<i)
{ans=i;pr=p*k;
cout<<p<<"\t"<<k<<endl;}
//cout<<ans<<"\t"<<pr<<endl;
}
int main()
{int count;
b[0]=1;
b[1]=2;b[2]=3;
for(int i=5;j<=10003;i+=2)
{int x=1;
for(int c=1;c<j;c++)
if(i%b[c]==0)
x=0;
if(x)
{b[j]=i;j++;}
}
ans=0;
for(int i=1;i<1000;i+=2)
{
for(int j=1;j<1000;j+=2)
{
check(i,j);
}
}
cout<<endl<<ans<<"\t"<<pr<<endl;
//check(1,41);
return 0;
}