結果
| 問題 |
No.389 ロジックパズルの組み合わせ
|
| コンテスト | |
| ユーザー |
👑 testestest
|
| 提出日時 | 2016-07-08 22:48:12 |
| 言語 | C90 (gcc 12.3.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 386 bytes |
| コンパイル時間 | 64 ms |
| コンパイル使用メモリ | 26,240 KB |
| 最終ジャッジ日時 | 2025-02-20 00:19:54 |
| 合計ジャッジ時間 | 1,640 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.c:3:1: warning: data definition has no type or storage class
3 | n,k,m,i,s;
| ^
main.c: In function 'c':
main.c:6:9: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
6 | for(int i=1;i<=k;i++)s=s*(n-i+1)%P*inv[i]%P;
| ^~~
main.c:6:9: note: use option '-std=c99', '-std=gnu99', '-std=c11' or '-std=gnu11' to compile your code
main.c: In function 'mod':
main.c:9:16: error: 'for' loop initial declarations are only allowed in C99 or C11 mode
9 | mod(){inv[1]=1;for(int i=2;i<=1000000;i++)inv[i]=inv[P%i]*(P-P/i)%P;}
| ^~~
main.c: In function 'main':
main.c:12:9: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
12 | scanf("%d",&n);
| ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
+++ |+#include <stdio.h>
1 | #define P 1000000007
main.c:16:14: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch]
16 | else printf("%lld",c(n-s+1,i));
| ^~~~~~
main.c:16:14: note: include '<stdio.h>' or provide a declaration of 'printf'
ソースコード
#define P 1000000007
long long inv[1000010];
n,k,m,i,s;
long long c(int n,int k){
long long s=1;
for(int i=1;i<=k;i++)s=s*(n-i+1)%P*inv[i]%P;
return s;
}
mod(){inv[1]=1;for(int i=2;i<=1000000;i++)inv[i]=inv[P%i]*(P-P/i)%P;}
main(){
mod();
scanf("%d",&n);
for(;~scanf("%d",&k);i++)s+=k;
if(s==0)puts("1");
else if(s+i-1>n)puts("NA");
else printf("%lld",c(n-s+1,i));
return 0;
}
testestest