forked from wandering007/ProjectEuler
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP29.cpp
More file actions
90 lines (90 loc) · 1.68 KB
/
P29.cpp
File metadata and controls
90 lines (90 loc) · 1.68 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include<iostream>
#include<fstream>
#include<string>
#include<queue>
#include<stack>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#define MAXN 1002001
#define LL long long
#define eps 1e-8
#define inf 0x3f3f3f3f
using namespace std;
int make[105]={}, composite[1001];
void getcomposite()
{
int p = 2, t = 1,vis[1001]={};
while(p<=700)
{
for(int i=p*2;i<=1000;i+=p)
vis[i] = 1;
p++;
while(vis[p])
{
if(p>100)
composite[t++] = p;
p++;
}
}
}
bool PowRange_100(int x, int n)
{
LL res = 1LL;
while(n--)
{
res*=x;
if(res>100)
return false;
}
return true;
}
bool findSuitable(int k, int n)
{
int t = sqrt(k)+1;
bool p;
for(int i = 2;i<=t;i++)
{
if(k%i==0)
{
p = PowRange_100(n,i);
if(k/i<=100&&p)
return true;
if(p == false)
return false;
}
}
return false;
}
int Num(int n)
{
int res = 99;
if(n>10) return res;
for(int k=composite[1],j=1;k<=600;k = composite[++j])
{
if(findSuitable(k,n))
res++;
}
return res;
}
int main()
{
int terms = 0;
getcomposite();
for(int i=2; i<=10; i++)
for(int j = i * i; j <= 100; j *= i)
make[j] = 1;
for(int i=2;i<=100;i++)
if(!make[i])
terms += Num(i);
printf("%d\n",terms);
return 0;
}