爆0求调
查看原帖
爆0求调
1385040
Moonlit_River_楼主2024/9/7 13:46

qwq

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N=55;
ll a[10000],b[10000],n,sum;
int main()
{
    cin>>n;
    a[0]=1;
	b[0]=1;
    for(int i=2;i<=n;i++)
	{
        for(int j=0;j<N;j++)
        {
		    b[j]*=i;
		}
        for(int j=0;j<N;j++)
        {
            if (b[j]>9)
			{
                b[j+1]+=b[j]/10;
                b[j]%=10;
            }
        }
        for (int j=0;j<N;j++)
		{
            a[j]+=b[j];
            if (a[j]>9)
			{
                a[j+1]+=a[j]/10;
                a[j]%=10;
            }
        }
    }
    for(int i=100;i>=0&&a[i]==0;i--)
    {
    	sum++;
	}
    for(int j=sum;j>=0;j--)
	{
		cout<<a[j];
	}
    return 0;
}
2024/9/7 13:46
加载中...