結果
問題 |
No.502 階乗を計算するだけ
|
ユーザー |
|
提出日時 | 2017-04-08 00:07:00 |
言語 | C90 (gcc 12.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 459 bytes |
コンパイル時間 | 101 ms |
コンパイル使用メモリ | 20,608 KB |
実行使用メモリ | 8,220 KB |
最終ジャッジ日時 | 2024-07-16 03:29:01 |
合計ジャッジ時間 | 2,992 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 32 TLE * 1 -- * 19 |
コンパイルメッセージ
main.c: In function ‘main’: main.c:19:9: warning: ignoring return value of ‘scanf’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 19 | scanf("%lld",&n); | ^~~~~~~~~~~~~~~~
ソースコード
#include<stdio.h> long long fact(long long s,long long e){ if(e==s) return e; long long ans=1; if((e-s+1)%2==1){ ans=e; e--; } ans*=fact(s,s+(e-s+1)/2-1); ans%=1000000007; ans*=fact(s+(e-s+1)/2,e); ans%=1000000007; return ans; } int main(int argc, char const *argv[]){ long long n,p=1000000007,ans=1,i; scanf("%lld",&n); if(n==0) printf("1\n"); else if(n<p){ ans=fact(1,n); printf("%lld\n",ans); }else{ printf("0\n"); } return 0; }