結果

問題 No.389 ロジックパズルの組み合わせ
ユーザー 👑 testestesttestestest
提出日時 2016-07-08 22:48:12
言語 C90
(gcc 12.3.0)
結果
AC  
実行時間 48 ms / 2,000 ms
コード長 386 bytes
コンパイル時間 861 ms
コンパイル使用メモリ 20,480 KB
実行使用メモリ 9,344 KB
最終ジャッジ日時 2024-10-13 06:13:28
合計ジャッジ時間 5,074 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 99
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:3:1: warning: data definition has no type or storage class
    3 | n,k,m,i,s;
      | ^
main.c:3:1: warning: type defaults to ‘int’ in declaration of ‘n’ [-Wimplicit-int]
main.c:3:3: warning: type defaults to ‘int’ in declaration of ‘k’ [-Wimplicit-int]
    3 | n,k,m,i,s;
      |   ^
main.c:3:5: warning: type defaults to ‘int’ in declaration of ‘m’ [-Wimplicit-int]
    3 | n,k,m,i,s;
      |     ^
main.c:3:7: warning: type defaults to ‘int’ in declaration of ‘i’ [-Wimplicit-int]
    3 | n,k,m,i,s;
      |       ^
main.c:3:9: warning: type defaults to ‘int’ in declaration of ‘s’ [-Wimplicit-int]
    3 | n,k,m,i,s;
      |         ^
main.c:9:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
    9 | mod(){inv[1]=1;for(int i=2;i<=1000000;i++)inv[i]=inv[P%i]*(P-P/i)%P;}
      | ^~~
main.c:10:1: warning: return type defaults to ‘int’ [-Wimplicit-int]
   10 | main(){
      | ^~~~
main.c: In function ‘main’:
main.c:12:9: warning: implicit declaration of function ‘scanf’ [-Wimplicit-function-declaration]
   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:12:9: warning: incompatible implicit declaration of built-in function ‘scanf’ [-Wbuiltin-declaration-mismatch]
   12 |         scanf("%d",&n);
      |         ^~~~~
main.c:12:9: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’
main.c:14:17: warning: implicit declaration of function ‘puts’ [-Wimplicit-function-declaration]
   14 |         if(s==0)puts("1");
      |                 ^~~~
main.c:14:17: note: include ‘<stdio.h>’ or provide a declaration of ‘puts’
main.c:16:14: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration]
   16 |         else printf("%lld",c(n-s+1,i));
      |              ^~~~~~
main.c:16:14: note: include ‘<stdio.h

ソースコード

diff #

#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;
}
0