結果

問題 No.502 階乗を計算するだけ
ユーザー kurenai3110
提出日時 2017-04-08 00:34:12
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 452 ms / 1,000 ms
コード長 573 bytes
コンパイル時間 624 ms
コンパイル使用メモリ 66,520 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-07-16 03:34:13
合計ジャッジ時間 4,431 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 52
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
using namespace std;
#define MOD (int)(1e9+7)

long long umekomi[] = { 927880474,933245637,668123525,429277690,733333339,724464507,957939114,203191898,586445753,698611116 };

int main()
{
	long long n;
	cin >> n;

	if (n >= MOD)cout << 0 << endl;
	else {
		long long a = 1;
		for (long long i = n; i > 1; i--) {
			if (i % (int)(1e8) == 0) {
				a *= umekomi[i / (int)(1e8) - 1];
				a %= MOD;
				break;
			}
			a *= i;
			a %= MOD;
		}
		cout << a << endl;
	}

	return 0;
}

0