forked from wandering007/ProjectEuler
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP16.cpp
More file actions
49 lines (49 loc) · 1006 Bytes
/
P16.cpp
File metadata and controls
49 lines (49 loc) · 1006 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
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<math.h>
#include<string>
#include<queue>
#include<stack>
#include<vector>
#define MAXN 1000000
#define LL long long
#define eps 1e-8
#define inf 0x3f3f3f3f
using namespace std;
int main()
{
int digit[400];
memset(digit,-1,sizeof(digit));
digit[0] = 0;
digit[1] = 2;
int c=0,d,temp;
int N=999;
while(N--)
{
d = 1;
while(digit[d]!=-1||c!=0)
{
if(digit[d]==-1)
{
digit[d] = c;
c = 0;
d++;
continue;
}
temp = digit[d]*2+c;
c = temp/10;
digit[d] = temp%10;
d++;
}
}
int sum = 0;
d = 1;
while(digit[d]!=-1)
sum+=digit[d++];
printf("%d is the sum of the digits of the number 2^1000\n",sum);
return 0;
}