zoukankan      html  css  js  c++  java
  • 关于阶乘【非打表

    /*大数阶乘*/
    
    
    #include <bits/stdc++.h>
    using namespace std;
    typedef long long LL;
    #define N 100005
    inline int read(){
        int s=0,w=1;
        char ch=getchar();
        while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
        while(ch>='0'&&ch<='9'){s=s*10+ch-'0';ch=getchar();}
        return s*w;
    }
    int qy[N]={1};
    int main()
    {
        int n=read();
        int l=1,h=0;
        for(int i=2;i<=n;i++)
        {
            for(int j=1;j<=l;j++)
            {
                int temp=qy[j-1]*i+h;
                qy[j-1]=temp%10;
                h=temp/10;
            }
            while(h)
            {
                l++;
                qy[l-1]=h%10;
                h/=10;
            }
        }
        for(int i=l-1;i>=0;i--) cout<<qy[i];
        cout<<endl;
    }
  • 相关阅读:
    p1706 全排列
    2089烤鸡(类似于选数问题)
    1036选数
    bfs
    A-E
    A-3
    百题A-2
    百题A-1
    二级概念题
    随记
  • 原文地址:https://www.cnblogs.com/Aaaamber/p/11269534.html
Copyright © 2011-2022 走看看