zoukankan      html  css  js  c++  java
  • nyoj 164 Game of Connections

     

    Game of Connections

    时间限制:1000 ms  |  内存限制:65535 KB
    难度:3
     
    描述
    This is a small but ancient game. You are supposed to write down the numbers 1, 2, 3, . . . , 2n - 1, 2n consecutively in clockwise order on the ground to form a circle, and then, to draw some straight line segments to connect them into number pairs. Every number must be connected to exactly one another. 
    And, no two segments are allowed to intersect. 
    It's still a simple game, isn't it? But after you've written down the 2n numbers, can you tell me in how many different ways can you connect the numbers into pairs? Life is harder, right?
     
    输入
    Each line of the input file will be a single positive number n, except the last line, which is a number -1.
    You may assume that 1 <= n <= 100.
    输出
    For each n, print in a single line the number of ways to connect the 2n numbers into pairs
    样例输入
    2
    3
    -1
    样例输出
    2
    5
    来源
    POJ
    上传者
    iphxer
    求卡特南数 我直接打表的
    嘿嘿标程是用java 写的 其实我也想用java来写的 java写大数挺好的
    View Code
      1  
      2 #include <stdio.h>
      3 
      4 char list[100][100]={
      5   "1",
      6   "2",
      7   "5",
      8   "14",
      9   "42",
     10   "132",
     11   "429",
     12   "1430",
     13   "4862",
     14   "16796",
     15   "58786",
     16   "208012",
     17   "742900",
     18   "2674440",
     19   "9694845",
     20   "35357670",
     21   "129644790",
     22   "477638700",
     23   "1767263190",
     24   "6564120420",
     25   "24466267020",
     26   "91482563640",
     27   "343059613650",
     28   "1289904147324",
     29   "4861946401452",
     30   "18367353072152",
     31   "69533550916004",
     32   "263747951750360",
     33   "1002242216651368",
     34   "3814986502092304",
     35   "14544636039226909",
     36   "55534064877048198",
     37   "212336130412243110",
     38   "812944042149730764",
     39   "3116285494907301262",
     40   "11959798385860453492",
     41   "45950804324621742364",
     42   "176733862787006701400",
     43   "680425371729975800390",
     44   "2622127042276492108820",
     45   "10113918591637898134020",
     46   "39044429911904443959240",
     47   "150853479205085351660700",
     48   "583300119592996693088040",
     49   "2257117854077248073253720",
     50   "8740328711533173390046320",
     51   "33868773757191046886429490",
     52   "131327898242169365477991900",
     53   "509552245179617138054608572",
     54   "1978261657756160653623774456",
     55   "7684785670514316385230816156",
     56   "29869166945772625950142417512",
     57   "116157871455782434250553845880",
     58   "451959718027953471447609509424",
     59   "1759414616608818870992479875972",
     60   "6852456927844873497549658464312",
     61   "26700952856774851904245220912664",
     62   "104088460289122304033498318812080",
     63   "405944995127576985730643443367112",
     64   "1583850964596120042686772779038896",
     65   "6182127958584855650487080847216336",
     66   "24139737743045626825711458546273312",
     67   "94295850558771979787935384946380125",
     68   "368479169875816659479009042713546950",
     69   "1440418573150919668872489894243865350",
     70   "5632681584560312734993915705849145100",
     71   "22033725021956517463358552614056949950",
     72   "86218923998960285726185640663701108500",
     73   "337485502510215975556783793455058624700",
     74   "1321422108420282270489942177190229544600",
     75   "5175569924646105559418940193995065716350",
     76   "20276890389709399862928998568254641025700",
     77   "79463489365077377841208237632349268884500",
     78   "311496878311103321137536291518809134027240",
     79   "1221395654430378811828760722007962130791020",
     80   "4790408930363303911328386208394864461024520",
     81   "18793142726809884575211361279087545193250040",
     82   "73745243611532458459690151854647329239335600",
     83   "289450081175264899454283846029490767264392230",
     84   "1136359577947336271931632877004667456667613940",
     85   "4462290049988320482463241297506133183499654740",
     86   "17526585015616776834735140517915655636396234280",
     87   "68854441132780194707888052034668647142985206100",
     88   "270557451039395118028642463289168566420671280440",
     89   "1063353702922273835973036658043476458723103404520",
     90   "4180080073556524734514695828170907458428751314320",
     91   "16435314834665426797069144960762886143367590394940",
     92   "64633260585762914370496637486146181462681535261000",
     93   "254224158304000796523953440778841647086547372026600",
     94   "1000134600800354781929399250536541864362461089950800",
     95   "3935312233584004685417853572763349509774031680023800",
     96   "15487357822491889407128326963778343232013931127835600",
     97   "60960876535340415751462563580829648891969728907438000",
     98   "239993345518077005168915776623476723006280827488229600",
     99   "944973797977428207852605870454939596837230758234904050",
    100   "3721443204405954385563870541379246659709506697378694300",
    101   "14657929356129575437016877846657032761712954950899755100",
    102   "57743358069601357782187700608042856334020731624756611000",
    103   "227508830794229349661819540395688853956041682601541047340",
    104   "896519947090131496687170070074100632420837521538745909320"
    105 };
    106 
    107 int main(void)
    108 {
    109  int k;
    110  while (scanf("%ld",&k)==1)
    111  {
    112   if (k==-1)
    113    break;
    114   printf("%s\n",list[k-1]);
    115  }
    116  return 0;
    117 }
    118         
  • 相关阅读:
    Java设计模式四: 原型模式(Prototype Pattern)
    Java设计模式六:观察者模式(Observer)
    Java设计模式九:状态模式(State)
    Windows 8 开发系列 自定义Gridview 绑定列表数据时出错
    Windows 8 开发系列如何修改系统样式
    Windows 8 开发系列全局资源App.xml的ContentFontsize会导致应用退出
    Windows 8 开发系列如何使状态栏不重复点击
    thinkpad E430 如何实现Fn键锁定或和功能键互换顺序
    Windows 8 开发系列应用挂起
    Windows 8 Metro 应用开发App Bar问题
  • 原文地址:https://www.cnblogs.com/wujianwei/p/2637031.html
Copyright © 2011-2022 走看看