<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12
      書山有徑勤為路>>>>>>>>

      <<<<<<<<學海無涯苦作舟!

      動態規劃解決USACO——Number Triangles

       

      Description

       

      Consider the number triangle shown below. Write a program that calculates the highest sum

      of numbers that can be passed on a route that starts at the top and ends somewhere on

      the base. Each step can go either diagonally down to the left or diagonally down to the right.

                7
      
              3   8
      
            8   1   0
      
          2   7   4   4
      
        4   5   2   6   5
      

      In the sample above, the route from 7 to 3 to 8 to 7 to 5 produces the highest sum: 30.

       

      Input

      The first line contains R (1 <= R <= 1000), the number of rows. Each subsequent line contains the

      integers for that particular row of the triangle. All the supplied integers are non-negative and

      no larger than 100.

      Output

      A single line containing the largest sum using the traversal specified.

      Sample Input

      5
      7
      3 8
      8 1 0
      2 7 4 4
      4 5 2 6 5

      Sample Output

      30

       

      這個是一道十分簡單的題目,就是用動規去做,

      下面有詳細的解釋。

      #include "iostream"

      using namespace std;

      #define Max 1005

      int a[Max][Max];

      int R;

      int Find()

      {

      for(int i=R-1;i>0;i--)

      {

      for(int j=1;j<=i;j++)

      {

      a[i][j] += max(a[i+1][j],a[i+1][j+1]); //從倒數第二層開始運算,將下一層的較大數往上加,

                                                                                    //當加到第一層的時候,自然的就是最大值了

      }

      }

      return a[1][1];

      }

      int main()

      {

      while(cin>>R)

      {

      for(int i=1; i<=R; i++)

      for(int j=1; j<=i; j++)

      cin>>a[i][j];

      cout<<Find()<<endl;

      }

      }

      posted on 2011-10-16 10:50  More study needed.  閱讀(919)  評論(0)    收藏  舉報

      導航

      書山有徑勤為路>>>>>>>>

      <<<<<<<<學海無涯苦作舟!

      主站蜘蛛池模板: 亚洲精品综合网二三区| 日本熟妇XXXX潮喷视频| 一日本道伊人久久综合影| 国产粉嫩区一区二区三区| 无遮无挡爽爽免费视频| 亚洲精品二区在线播放| 国产精品色一区二区三区| 国产成人AV男人的天堂| 久久亚洲精品国产精品| 精品国产中文字幕在线| 婺源县| 亚洲一品道一区二区三区| 国产精品自拍午夜福利| 精品国产乱码久久久久久影片| 亚洲人妻一区二区精品| 国产精品久线在线观看| 亚洲精品专区在线观看| 午夜成人无码免费看网站| 国产偷国产偷亚洲高清人| 欧美颜射内射中出口爆在线 | 欧美日韩综合网| 麻豆a级片| 国产亚洲亚洲国产一二区| 精品久久久久久亚洲综合网| 成人欧美一区二区三区在线观看| 欧美 亚洲 日韩 在线综合| 实拍女处破www免费看| 九九热精品视频在线免费| 久久久久久毛片免费播放| 亚洲韩国精品无码一区二区三区| 9久久精品视香蕉蕉| 亚洲精品tv久久久久久久久久| 日产国产一区二区不卡| 亚洲国产中文字幕精品| 国产精品视频一区二区不卡| 国产成人欧美一区二区三区| 国产日产亚洲系列av| 无码欧美毛片一区二区三| 任我爽精品视频在线播放| 中国女人熟毛茸茸A毛片| 樱花草视频www日本韩国|