結果

問題 No.502 階乗を計算するだけ
ユーザー masa
提出日時 2017-04-08 01:14:13
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
TLE  
実行時間 -
コード長 752 bytes
コンパイル時間 603 ms
コンパイル使用メモリ 69,328 KB
実行使用メモリ 6,948 KB
最終ジャッジ日時 2024-07-16 03:38:14
合計ジャッジ時間 11,118 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 46 TLE * 6
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

long long mod = 1e9 + 7;
long long sub = 1e8;

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

void calc_mod_fact() {
	long long x = 1;

	cout << x << endl;
	for (int i = 1; i <= sub * 10; i++) {
		x = x * i % mod;
		if (i % sub == 0) {
			cout << x << endl;
		}
	}
}

int main() {
	// calc_mod_fact();

	long long n;
	cin >> n;

	if (n >= mod) {
		cout << 0 << endl;
		return 0;
	}
	int idx = n / sub;

	long long x = fact[idx];
	for (int i = idx * sub + 1; i <= n; i++) {
		x = x * i % mod;
	}

	cout << x << endl;
	return 0;
}
0