zoukankan      html  css  js  c++  java
  • USACO3.21Factorials

    枚举

     1 #include <iostream>
     2 /*
     3     ID: shangca2
     4     LANG: C++
     5     TASK: fact4
     6  */
     7 #include<cstdio>
     8 #include<cstring>
     9 #include<iostream>
    10 
    11 using namespace std;
    12 int di[5000];
    13 int main()
    14 {
    15     freopen("fact4.in","r",stdin);
    16     freopen("fact4.out","w",stdout);
    17     int i,j,k,n,g=0;
    18     di[0] = 1;
    19     cin>>n;
    20     for(i = 1 ; i <= n ; i++)
    21     {
    22         for(j=0 ; j <= g ; j++)
    23         di[j] *= i;
    24         for(j = 0 ; j <= g ; j++)
    25         {
    26             if(di[j]>9)
    27             {
    28                 di[j+1] += di[j]/10;
    29                 di[j] = di[j]%10;
    30                 if(j+1>g)
    31                 g = j+1;
    32             }
    33         }
    34     }
    35     k=0;
    36     while(di[k]==0&&k<=g)
    37     k++;
    38     cout<<di[k]<<endl;
    39     return 0;
    40 }
    View Code
  • 相关阅读:
    三维几何模板
    凸包
    计算几何 部分模板
    几何模板
    高斯消元模板
    tarjin求割点
    在无向图中找最短桥(tarjan)
    线段树
    错排问题
    NABCD分析
  • 原文地址:https://www.cnblogs.com/shangyu/p/3123136.html
Copyright © 2011-2022 走看看