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 }
     
  • 相关阅读:
    【中山纪念中学六年级模拟赛】方格翻转 题解
    高斯消元
    net 控件开发资料
    使用自定义验证组件库扩展 Windows 窗体
    POJ 3032
    UVa 10878 Decode the tape
    C语言I博客作业03
    第十周助教总结
    第十二周助教总结
    C语言I博客作业06
  • 原文地址:https://www.cnblogs.com/a2985812043/p/7263180.html
Copyright © 2011-2022 走看看