-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path37a.cpp
More file actions
66 lines (62 loc) · 774 Bytes
/
Copy path37a.cpp
File metadata and controls
66 lines (62 loc) · 774 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
#include<iostream>
#include<fstream>
#include<cmath>
using namespace std;
int j=3;
int b[10003];
int isprime(int f)
{
for(int i=0;i<10003;i++)
if(b[i]==f)
return 1;
return 0;
}
int ans=0;
void check(int p)
{
int q=p,u=p,l=0;
while(q>0)
{
if(isprime(q))
ans+=p;
q/=10;
l++;
}
while(u>0)
{
if(isprime(q))
ans+=p;
q%=(int)pow(10,--l);
}
}
int main()
{
b[0]=1;
b[1]=2;b[2]=3;
ofstream myfile;
myfile.open ("7.txt");
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++;}
}
// for(int i=1;i<j;i++)
//myfile<<b[i]<<"\r\n";
//myfile.close();
check(37);
check(3373);
check(3733);
check(3793);
check(3797);
check(7333);
check(7393);
check(7793);
check(7993);
check(7937);
check(73);
cout<<ans;
return 0;
}