0pts, 大佬求调qwq
查看原帖
0pts, 大佬求调qwq
636358
WindyDay楼主2023/1/2 09:30

code\texttt{code} :

#include <iostream>
using namespace std;

struct node
{
	int org, add;
};

node temp[205];
int ans[205];

void clear()
{
	for(int i = 1; i <= 200; i++)
	{
		temp[i].org = 0;
		temp[i].org = 0;
	}
}

void once(int t)
{
	int cur = 1;
	while(temp[cur].org)
	{
		int th = temp[cur].org * t;
		temp[cur + 1].add = th / 10;
		temp[cur].org = th % 10;
		cur++;
	}
	
}

void multi(int limit)
{
	clear();
	temp[1].org = 1;
	temp[1].add = 0;
	for(int i = 1; i <= limit; i++)
	{
		once(i);
		for(int i = 1; i <= 200; i++)
		{
			temp[i].org += temp[i].add;
			temp[i].add = 0;
		}
	}
	
}

void add()
{
	int cur = 1;
	do
	{
		ans[cur] += (temp[cur].org + temp[cur].add);
		ans[cur + 1] += ans[cur] / 10;
		ans[cur] %= 10;
		cur++;
	} while(ans[cur]);
}

int main()
{
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++)
	{
		multi(i);
		add();
	}
	int cur = 1;
	while(ans[cur] != 0)
	{
		cur++;
	}
	cur--;
	for(int i = cur; i >= 1; i--)
	{
		cout << ans[i];
	}
}

2023/1/2 09:30
加载中...