zoukankan      html  css  js  c++  java
  • hdu 5366 组合数 *

    考虑放1个,2个。。。。的情况,相加就是最后的结果

     1 #include<cstdio>
     2 #include<iostream>
     3 #include<algorithm>
     4 #include<cstring>
     5 #include<cmath>
     6 #include<queue>
     7 #include<map>
     8 using namespace std;
     9 #define MOD 1000000007
    10 const int INF=0x3f3f3f3f;
    11 const double eps=1e-5;
    12 typedef long long ll;
    13 #define cl(a) memset(a,0,sizeof(a))
    14 #define ts printf("*****
    ");
    15 const int MAXN=1005;
    16 int n,m,tt;
    17 ll c[MAXN][MAXN];
    18 
    19 void init()     //初始化组合数
    20 {
    21     c[0][0]=c[1][0]=c[1][1]=1;
    22     for(int i=2;i<=62;i++)
    23     {
    24         c[i][0]=1;
    25         for(int j=1;j<i;j++)
    26             c[i][j]=c[i-1][j]+c[i-1][j-1];
    27         c[i][i]=1;
    28     }
    29 }
    30 int main()
    31 {
    32     int i,j,k,ca=1;
    33     #ifndef ONLINE_JUDGE
    34     freopen("1.in","r",stdin);
    35     #endif
    36     init();
    37     while(scanf("%d",&n)!=EOF)
    38     {
    39         int r=1;
    40         ll sum=0;
    41         while(n-3*(r-1)-1+r>0)
    42         {
    43             sum+=c[n-3*(r-1)-1+r][r];
    44             r++;
    45         }
    46         printf("%I64d
    ",sum);
    47     }
    48 }
  • 相关阅读:
    隐式类型转换
    STL::allocator rebind
    Proxy Class(代理类)
    C++ 没有合适的默认构造函数(无参数构造函数)
    E
    C
    Multiplication Puzzle POJ
    Brackets POJ
    Halloween Costumes LightOJ
    ACwing 139. 回文子串的最大长度(二分+Hash)
  • 原文地址:https://www.cnblogs.com/cnblogs321114287/p/4715260.html
Copyright © 2011-2022 走看看