結果
問題 | No.117 組み合わせの数 |
ユーザー | ciel |
提出日時 | 2015-01-13 15:54:58 |
言語 | C90 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 89 ms / 5,000 ms |
コード長 | 523 bytes |
コンパイル時間 | 221 ms |
コンパイル使用メモリ | 21,760 KB |
実行使用メモリ | 48,340 KB |
最終ジャッジ日時 | 2024-06-22 04:37:48 |
合計ジャッジ時間 | 777 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
コンパイルメッセージ
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==-1&&K==0?1:N<K?0:(__int128_t)fact[N]*factr[K]*factr[N-K]%MOD); | ^~~~~~ main.c:19:25: note: include ‘<stdio.h>’ or provide a declaration of ‘printf’ main.c:19:36: warning: format ‘%lld’ expects argument of type ‘long long int’, but argument 2 has type ‘__int128’ [-Wformat=] 19 | printf("%lld\n",N==-1&&K==0?1:N<K?0:(__int128_t)fact[N]*factr[K]*factr[N-K]%MOD); | ~~~^ | | | long long int
ソースコード
#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==-1&&K==0?1:N<K?0:(__int128_t)fact[N]*factr[K]*factr[N-K]%MOD); } } }