2022-09-05
查看原帖
2022-09-05
808489
Tom_catLLL楼主2022/11/3 17:11
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;

int main()
{
	int n, a[1001] = { 0 }, b[1001] = { 0 },i,j;
	cin >> n;
	a[0] = b[0] = 1;
	for (i = 2; i <= n; i++)
	{
		for (j = 0; j < 100; j++)
			a[j] *= i;
		for (j = 0; j < 100; j++)
		{
			if (a[j] > 9)
			{
				a[j + 1] += a[j] / 10;
				a[j] %= 10;
			}
		}
		for (j= 0; j < 100; j++)
		{
			b[j] += a[j];
			if (b[j] > 9)
			{
				b[j + 1] = b[j] / 10;
				b[j] %= 10;
			}
		}
	}
	for (i=100; i>=0 && b[i]==0;i--);
	for (j=i; j >= 0; j--)
		cout << b[j];
	system("pause");
	return 0;
}
2022/11/3 17:11
加载中...