隨筆 - 147  文章 - 71  trackbacks - 0
          <2009年9月>
          303112345
          6789101112
          13141516171819
          20212223242526
          27282930123
          45678910

          常用鏈接

          留言簿(1)

          隨筆分類(146)

          隨筆檔案(147)

          文章分類(28)

          文章檔案(28)

          喜歡的Blog

          搜索

          •  

          最新評論

          閱讀排行榜

          評論排行榜

          http://acm.fjnu.edu.cn/show?problem_id=2046
          動態規劃,求左下角矩陣。
          a[i][j]=a[i][j-1]+a[i-1][j];i<j;
          a[i][j]=a[i][j-1];i=j.
          import java.util.*;
          import java.io.*;

          public class ACM_2046{
              
              
          public static void main(String rgs[]) throws Exception
              
          {
                  BufferedReader stdin 
          = 
                      
          new BufferedReader(
                          
          new InputStreamReader(System.in));        
                  String line 
          = stdin.readLine();  
                  
          int i,j,k,n,m = Integer.parseInt(line);
                  
          long[][] a=new long[21][21];
                  
          for(i=0;i<21;i++)
                      a[i][
          0]=a[0][i]=1;
                  
          for(i=1;i<21;i++){
                      
          for(j=1;j<i;j++)
                          a[i][j]
          =a[i][j-1]+a[i-1][j];
                      a[i][j]
          =a[i][j-1];
                  }
                  
                  
          for(k=0;k<m;k++){
                      line 
          = stdin.readLine();
                      n 
          = Integer.parseInt(line);            
                      System.out.println(a[n][n]);
                      System.out.println();
                  }

              }

          }
          posted on 2009-09-23 10:08 飛翔天使 閱讀(191) 評論(0)  編輯  收藏 所屬分類: ACM
          主站蜘蛛池模板: 清涧县| 四会市| 钟山县| 东海县| 康保县| 中西区| 永寿县| 建昌县| 会泽县| 乌拉特中旗| 承德市| 福海县| 建德市| 黑山县| 上思县| 吉水县| 梁平县| 浏阳市| 荣昌县| 义马市| 上饶县| 镇赉县| 阿合奇县| 穆棱市| 深泽县| 松潘县| 莒南县| 漯河市| 论坛| 徐闻县| 金华市| 通江县| 巢湖市| 万山特区| 泗洪县| 景洪市| 都兰县| 建德市| 蒙城县| 平潭县| 长汀县|