forked from wandering007/ProjectEuler
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathP18.cpp
More file actions
34 lines (34 loc) · 734 Bytes
/
Copy pathP18.cpp
File metadata and controls
34 lines (34 loc) · 734 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
#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 a[130];
for(int i=1;i<=120;i++)
scanf("%d",&a[i]);
int level=14;
int sum = 91;
for(;level>=1;level--)
{
for(int id = sum+1;id<=sum+level;id++)
{
a[id]+=max(a[id+level],a[id+level+1]);//¶¯Ì¬¹æ»®
}
sum-=level-1;
}
printf("The maximum total from top to bottom of the triangle is %d\n",a[1]);
return 0;
}