結果
問題 | No.117 組み合わせの数 |
ユーザー | ciel |
提出日時 | 2015-01-13 15:47:51 |
言語 | C90 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 502 bytes |
コンパイル時間 | 196 ms |
コンパイル使用メモリ | 21,120 KB |
実行使用メモリ | 48,504 KB |
最終ジャッジ日時 | 2024-06-22 04:37:47 |
合計ジャッジ時間 | 773 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
コンパイルメッセージ
main.c: In function ‘main’: main.c:14:13: warning: implicit declaration of function ‘scanf’ [-Wimplicit-function-declaration] 14 | for(scanf("%d",&T);T--;){ | ^~~~~ main.c:1:1: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’ +++ |+#include <stdio.h> 1 | #define M 2000000 main.c:14:13: warning: incompatible implicit declaration of built-in function ‘scanf’ [-Wbuiltin-declaration-mismatch] 14 | for(scanf("%d",&T);T--;){ | ^~~~~ main.c:14:13: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’ main.c:16:27: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration] 16 | if(C=='P')printf("%lld\n",N<K?0:fact[N]*factr[N-K]%MOD); | ^~~~~~ main.c:16:27: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’ main.c:16:27: warning: incompatible implicit declaration of built-in function ‘printf’ [-Wbuiltin-declaration-mismatch] main.c:16:27: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’ main.c:19:25: warning: incompatible implicit declaration of built-in function ‘printf’ [-Wbuiltin-declaration-mismatch] 19 | printf("%lld\n",N<K||N<0?0:fact[N]*factr[K]*factr[N-K]%MOD); | ^~~~~~ main.c:19:25: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’
ソースコード
#define M 2000000 #define MOD 1000000007 long long inv[M],fact[M],factr[M]; int main(){ int i; for(i=0;i<M;i++)inv[i]=fact[i]=factr[i]=1; for(i=2;i<M;i++){ inv[i]=(MOD-MOD/i)*inv[MOD%i]%MOD; fact[i]=i*fact[i-1]%MOD; factr[i]=inv[i]*factr[i-1]%MOD; } int T,N,K; char C; for(scanf("%d",&T);T--;){ scanf("\n%c(%d,%d)",&C,&N,&K); if(C=='P')printf("%lld\n",N<K?0:fact[N]*factr[N-K]%MOD); else{ if(C=='H')N=N+K-1; printf("%lld\n",N<K||N<0?0:fact[N]*factr[K]*factr[N-K]%MOD); } } }