50分 求助 能帮忙改一下吗?我不知道要怎么改
查看原帖
50分 求助 能帮忙改一下吗?我不知道要怎么改
291489
xiexie楼主2021/2/2 21:55
#include<bits/stdc++.h>
using namespace std;
unsigned long long a[100001];
unsigned long long c[100001];
int main()
{
	int n;
	cin >> n;
	for(int i = 1;i <= 999;i++)
		a[i] = 0;
	a[1] = 1;
	int b = 1;
	int f = 1;
	for(int i = 1 ;i <= n;i++)
	{
		f = 1;
		int x = 0;
		for(int j = 1 ;j <= b;j++)
		{
			a[j] = a[j] * i + x;
			x = a[j] / 10;
			a[j] = a[j] % 10;
		
		}
		while(x > 0)
		{
			b++;
			a[b] += x;
			x = a[b]/10;
			a[b] %= 10;
		}
		for(int j = 1 ;j <= b;j++)
		{
			c[1] += a[j] * pow(10 , j - 1);
	
		}	
			x = c[1] / 10;
			c[1] %= 10; 
		while(x > 0)
		{
			++f;
			c[f] += x;
			x = c[f] / 10;
			c[f] %= 10;
		}
	}
	for(int i = f ;i >= 1;i--)
		cout << c[i]; 
	return 0;
}
2021/2/2 21:55
加载中...