結果

問題 No.502 階乗を計算するだけ
ユーザー Kmcode1
提出日時 2017-04-07 23:25:34
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
TLE  
実行時間 -
コード長 616 bytes
コンパイル時間 1,334 ms
コンパイル使用メモリ 159,284 KB
実行使用メモリ 13,884 KB
最終ジャッジ日時 2024-07-16 03:05:31
合計ジャッジ時間 4,520 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 32 TLE * 2 -- * 18
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:25:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   25 |         scanf("%lld", &n);
      |         ~~~~~^~~~~~~~~~~~

ソースコード

diff #

#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;




#define MOD 1000000007

long long int recfact(long long int start, long long int n) {
	long long int i;
	if (n <= 16) {
		long long int r = start;
		for (i = start + 1; i < start + n; i++) r *= i,r%=MOD;
		return r%MOD;
	}
	i = n / 2;
	return (recfact(start, i) * recfact(start + i, n - i))%MOD;
}
long long int factorial(long  n) { return recfact(1, n); }

int main(){
	long long int n;
	scanf("%lld", &n);
	if (n >= MOD){
		puts("0");
		return 0;
	}
	long long int c = factorial(n);
	printf("%lld\n", c);
	return 0;
}
0