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 }
     
  • 相关阅读:
    bzoj3514 Codechef MARCH14 GERALD07加强版
    差分数列(学习笔记)
    mysql 数据库 replace、regexp的用法
    30岁前男人需要完成的事
    硬盘故障修复十大攻略
    网络工程师考试必备知识
    系统不能正常关机
    忘记XP登入密码的9种解决办法
    Mysql全文搜索match...against的用法
    双绞线网线的连接方式
  • 原文地址:https://www.cnblogs.com/a2985812043/p/7263180.html
Copyright © 2011-2022 走看看