結果

問題 No.243 出席番号(2)
ユーザー testestesttestestest
提出日時 2017-11-09 01:47:35
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 131 ms / 2,000 ms
コード長 269 bytes
コンパイル時間 765 ms
コンパイル使用メモリ 30,208 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-05-03 07:56:18
合計ジャッジ時間 2,791 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 1 ms
5,248 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 7 ms
5,376 KB
testcase_04 AC 7 ms
5,376 KB
testcase_05 AC 6 ms
5,376 KB
testcase_06 AC 6 ms
5,376 KB
testcase_07 AC 6 ms
5,376 KB
testcase_08 AC 22 ms
5,376 KB
testcase_09 AC 22 ms
5,376 KB
testcase_10 AC 22 ms
5,376 KB
testcase_11 AC 22 ms
5,376 KB
testcase_12 AC 22 ms
5,376 KB
testcase_13 AC 47 ms
5,376 KB
testcase_14 AC 48 ms
5,376 KB
testcase_15 AC 48 ms
5,376 KB
testcase_16 AC 48 ms
5,376 KB
testcase_17 AC 48 ms
5,376 KB
testcase_18 AC 84 ms
5,376 KB
testcase_19 AC 84 ms
5,376 KB
testcase_20 AC 83 ms
5,376 KB
testcase_21 AC 84 ms
5,376 KB
testcase_22 AC 84 ms
5,376 KB
testcase_23 AC 131 ms
5,376 KB
testcase_24 AC 131 ms
5,376 KB
testcase_25 AC 129 ms
5,376 KB
testcase_26 AC 130 ms
5,376 KB
testcase_27 AC 130 ms
5,376 KB
testcase_28 AC 1 ms
5,376 KB
testcase_29 AC 1 ms
5,376 KB
testcase_30 AC 1 ms
5,376 KB
testcase_31 AC 1 ms
5,376 KB
testcase_32 AC 1 ms
5,376 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.c:1:1: warning: data definition has no type or storage class
    1 | P=1e9+7;
      | ^
main.c:1:1: warning: type defaults to 'int' in declaration of 'P' [-Wimplicit-int]
main.c:2:1: warning: data definition has no type or storage class
    2 | a[6000],n,t,ans,i,k;
      | ^
main.c:2:1: warning: type defaults to 'int' in declaration of 'a' [-Wimplicit-int]
main.c:2:9: warning: type defaults to 'int' in declaration of 'n' [-Wimplicit-int]
    2 | a[6000],n,t,ans,i,k;
      |         ^
main.c:2:11: warning: type defaults to 'int' in declaration of 't' [-Wimplicit-int]
    2 | a[6000],n,t,ans,i,k;
      |           ^
main.c:2:13: warning: type defaults to 'int' in declaration of 'ans' [-Wimplicit-int]
    2 | a[6000],n,t,ans,i,k;
      |             ^~~
main.c:2:17: warning: type defaults to 'int' in declaration of 'i' [-Wimplicit-int]
    2 | a[6000],n,t,ans,i,k;
      |                 ^
main.c:2:19: warning: type defaults to 'int' in declaration of 'k' [-Wimplicit-int]
    2 | a[6000],n,t,ans,i,k;
      |                   ^
main.c:4:1: warning: return type defaults to 'int' [-Wimplicit-int]
    4 | main(){
      | ^~~~
main.c: In function 'main':
main.c:5:9: warning: implicit declaration of function 'scanf' [-Wimplicit-function-declaration]
    5 |         scanf("%d",&n);
      |         ^~~~~
main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf'
  +++ |+#include <stdio.h>
    1 | P=1e9+7;
main.c:5:9: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch]
    5 |         scanf("%d",&n);
      |         ^~~~~
main.c:5:9: note: include '<stdio.h>' or provide a declaration of 'scanf'
main.c:10:9: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration]
   10 |         printf("%d",(ans+P)%P);
      |         ^~~~~~
main.c:10:9: note: include '<stdio.h>' or provide a declaration of 'printf'
main.c:10:9: warning: incompatible implicit declaration of built-in function 'p

ソースコード

diff #

P=1e9+7;
a[6000],n,t,ans,i,k;
long dp[6000],f;
main(){
	scanf("%d",&n);
	for(;~scanf("%d",&t);)a[t]++;
	f=dp[0]=1;
	for(k=0;k<n;k++)for(i=k;i>=0;i--)dp[i+1]=(dp[i+1]+dp[i]*a[k])%P;
	for(i=0;i<=n;f=(f*++i)%P)ans=(ans+(n-i&1?-1:1)*f*dp[n-i])%P;
	printf("%d",(ans+P)%P);
}
0