爆 0 求助。
查看原帖
爆 0 求助。
677091
MnZnOIer楼主2024/7/9 15:51

贪心策略和高精都没有问题。(确信)

#include <bits/stdc++.h>
#define int long long
using namespace std;
int n, cnt[10005], s, c, ans[10005], len = 1;
void print (){for (int i = len; i > 0; -- i)cout << ans[i];cout << '\n';}
signed main ()
{
	ios::sync_with_stdio (0), cin.tie (0), cout.tie (0);
	cin >> n;
	for (c = 2; s + c <= n; ++ c)
	{
		s += c;
		cnt[c - 1] = c;
	}
	-- c;
	-- c;
	s = n - s;
	if (s > 0)
	{
		if (s == c + 1)++ cnt[c];
		for (int i = c - s + 1; i <= c; ++ i)++ cnt[i];
	}
	ans[1] = cnt[1];
	for (int i = 2; i <= c; ++ i)
	{
//		cout << cnt[i] << '\n';
		int j;
		for (j = len; j > 0; -- j)ans[j] *= cnt[i];
		j = 1;
		while (1)
		{
			if (! ans[j] && j > len)break;
			ans[j + 1] += ans[j] / 10;
			ans[j] %= 10;
			++ j;
		}
		len = j - 1;
//		print ();
//		cout << '\n';
	}
	print ();
	return 0;
}
2024/7/9 15:51
加载中...