看不懂

P1216 [USACO1.5] [IOI1994]数字三角形 Number Triangles

NIYUJIA @ 2024-01-21 14:42:32

一点看不懂,有大佬带一下吗


by Liuyilin1 @ 2024-01-21 14:43:10

什么东西看不懂呀???


by ragwort @ 2024-01-21 14:50:00

6


by yuxiaotian @ 2024-01-25 16:23:55

@NIYUJIA 这孩子......没救了,直接上代码


by yuxiaotian @ 2024-01-25 16:24:27

@NIYUJIA

#include <iostream>
using namespace std;

int main(){
    int n;
    cin >> n;   //n=5;
    int a[n+1][n+1];

    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=1; j<=i; j++){
         if (a[i+1][j]>a[i+1][j+1])
            a[i][j] += a[i+1][j];
         else
            a[i][j] += a[i+1][j+1];
      }
    }

    cout << a[1][1];
    return 0;
}

by NIYUJIA @ 2024-01-27 08:17:38

@yuxiaotian 感谢大佬


by shenyeting @ 2024-02-03 09:39:57

@yuxiaotian有你这么教别人的吗?


by xieyiyang112 @ 2024-03-31 16:15:50

@NIYUJIA fw


|