結果

問題 No.500 階乗電卓
ユーザー elphe
提出日時 2024-12-24 19:51:06
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 482 bytes
コンパイル時間 1,076 ms
コンパイル使用メモリ 84,844 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-24 19:51:08
合計ジャッジ時間 2,066 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <iomanip>
#include <cstdint>

using namespace std;

int main()
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	uint64_t N, i, ans = 1;
	cin >> N;

	if (N >= 65)
	{
		cout << "000000000000\n";
		return 0;
	}

	bool overflow = false;
	for (i = 2; i <= N; ++i)
	{
		ans *= i;
		if (ans >= 1'000'000'000'000)
			overflow = true, ans %= 1'000'000'000'000;
	}

	if (overflow) cout << setfill('0') << right << setw(12);
	cout << ans << '\n';

	return 0;
}
0