#include<bits/stdc++.h> using namespace std; int a[1005][1005]; int main(){ int n; cin>>n; for(int i=1;i<=n;i++){ for(int j=1;j<=i;j++){ cin>>a[i][j]; } } for(int i=n-1;i>=1;i--){ for(int j=0;j<=i;j++){ a[i][j]=max(a[i+1][j],a[i+1][j+1])+a[i][j]; } } cout<<a[1][1]; return 0; }
标签:记录,int,代码,1005,三角形,EG.9 From: https://www.cnblogs.com/Ahuang1A/p/17572901.html