zoukankan      html  css  js  c++  java
  • A

    As we all know the Train Problem I, the boss of the Ignatius Train Station want to know if all the trains come in strict-increasing order, how many orders that all the trains can get out of the railway. 

    InputThe input contains several test cases. Each test cases consists of a number N(1<=N<=100). The input is terminated by the end of file. 
    OutputFor each test case, you should output how many ways that all the trains can get out of the railway. 
    Sample Input

    1
    2
    3
    10

    Sample Output

    1
    2
    5
    16796

    Hint

    The result will be very large, so you may not process it by 32-bit integers.



     1 #include <iostream>
     2 #include <string.h>
     3 using namespace std;
     4 
     5 const int MAX = 305;
     6 int a[MAX][MAX];
     7 
     8 
     9 void chengf(int x,int i)
    10 {
    11     int temp = 0;;
    12     for(int j = 300;j >=0;j--)
    13     {
    14         temp = a[i-1][j]*x + temp;
    15         a[i][j] = temp % 10;
    16         temp = temp / 10;
    17 
    18     }
    19 }
    20 
    21 void chuf(int x,int i)
    22 {
    23     int temp = 0;
    24     for(int j = 0;j <=300;j++)
    25     {
    26         temp = temp *10 + a[i][j];
    27         a[i][j] = temp / x;
    28         temp = temp %x;
    29     }
    30 }
    31 
    32 void DP()
    33 {
    34     memset(a,0,sizeof(a));
    35     a[1][300] = 1;
    36     for(int i = 2;i <= 100;i++)
    37     {
    38         int temp = 4*i - 2;
    39         chengf(temp,i);
    40         temp = i + 1;
    41         chuf(temp,i);
    42     }
    43 }
    44 
    45 int main()
    46 {
    47    int n;
    48    DP();
    49    while(cin>>n)
    50    {
    51        int temp = 0;
    52         for(int i = 0;i <= 300;i++)
    53         {
    54             if(a[n][i]!=0)
    55             {
    56                 temp = i;
    57                 break;
    58             }
    59         }
    60         for(int i = temp;i <=300;i++)
    61             cout<<a[n][i];
    62         cout<<endl;
    63 
    64    }
    65 
    66     return 0;
    67 }
     
  • 相关阅读:
    js去前后空格
    IE7以上支持Fiddler 监听本地
    IE8 scriptX print 无法使用的bug
    那些相见恨晚的 JavaScript 技巧
    oracle sql
    JS人民币金额转大写程序
    div自适应高度
    .NET Remoting 使用最佳实践,(部分翻译)
    对DataTable 进行Distinct操作
    用财富的眼光看知识管理
  • 原文地址:https://www.cnblogs.com/a2985812043/p/7263180.html
Copyright © 2011-2022 走看看