forked from wandering007/ProjectEuler
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP63.cpp
More file actions
63 lines (62 loc) · 1.36 KB
/
P63.cpp
File metadata and controls
63 lines (62 loc) · 1.36 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
#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>
#include<iomanip>
#define MAXN 100000
#define BASE 15
#define LL long long
#define eps 1e-6
#define inf 0x3f3f3f3f
using namespace std;
//attention: 9^20³¬³ölong long·¶Î§
int main()
{
double duration;
clock_t start = clock();
int num = 0, incre;
for(int i = 1; ; i++)
{
incre = 10 - ceil(pow(10, (i - 1.0) / i));//10 ^ (n - 1) <= k = base ^ i < 10 ^ n, base = bgn...9
if(0 == incre)
break;
num += incre;
}
printf("%d\n", num);
duration = (double)(clock() - start) / CLOCKS_PER_SEC;
printf("time cost: %lf\n", duration);
return 0;
}
/*another implementation
double a[10];
for(int i = 1; i<= 9; i++)
a[i] = log10((double)i);
for(int i = 1; ; i++)
{
incre = 0;
for(int j = bgn; j <= 9; j++)
{
if(i - 1.0 - eps <= a[j] * i)
{
incre = 10 - j;
bgn = j;
break;
}
}
if(0 == incre)
break;
num += incre;
}
*/