結果
問題 | No.1327 グラフの数え上げ |
ユーザー | tails |
提出日時 | 2020-12-24 23:28:04 |
言語 | C (gcc 12.3.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 571 bytes |
コンパイル時間 | 251 ms |
コンパイル使用メモリ | 30,848 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-21 17:06:31 |
合計ジャッジ時間 | 3,508 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 299 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | AC | 1 ms
5,376 KB |
testcase_04 | AC | 1 ms
5,376 KB |
testcase_05 | AC | 1 ms
5,376 KB |
testcase_06 | AC | 1 ms
5,376 KB |
testcase_07 | AC | 1 ms
5,376 KB |
testcase_08 | AC | 1 ms
5,376 KB |
testcase_09 | AC | 42 ms
5,376 KB |
testcase_10 | TLE | - |
testcase_11 | AC | 1 ms
5,376 KB |
testcase_12 | AC | 1 ms
5,376 KB |
testcase_13 | AC | 1 ms
5,376 KB |
testcase_14 | AC | 1 ms
5,376 KB |
testcase_15 | AC | 1 ms
5,376 KB |
testcase_16 | AC | 1 ms
5,376 KB |
コンパイルメッセージ
main.c:30:1: warning: return type defaults to 'int' [-Wimplicit-int] 30 | main(){ | ^~~~ main.c: In function 'main': main.c:32:9: warning: implicit declaration of function 'read' [-Wimplicit-function-declaration] 32 | read(0,rbuf,sizeof rbuf); | ^~~~ main.c:39:25: warning: implicit declaration of function 'puts' [-Wimplicit-function-declaration] 39 | puts("0"); | ^~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'puts' +++ |+#include <stdio.h> 1 | #pragma GCC optimize("Ofast") main.c:40:25: warning: implicit declaration of function 'exit' [-Wimplicit-function-declaration] 40 | exit(0); | ^~~~ main.c:1:1: note: include '<stdlib.h>' or provide a declaration of 'exit' +++ |+#include <stdlib.h> 1 | #pragma GCC optimize("Ofast") main.c:40:25: warning: incompatible implicit declaration of built-in function 'exit' [-Wbuiltin-declaration-mismatch] 40 | exit(0); | ^~~~ main.c:40:25: note: include '<stdlib.h>' or provide a declaration of 'exit' main.c:45:9: warning: implicit declaration of function 'printf' [-Wimplicit-function-declaration] 45 | printf("%d\n",f); | ^~~~~~ main.c:45:9: note: include '<stdio.h>' or provide a declaration of 'printf' main.c:45:9: warning: incompatible implicit declaration of built-in function 'printf' [-Wbuiltin-declaration-mismatch] main.c:45:9: note: include '<stdio.h>' or provide a declaration of 'printf'
ソースコード
#pragma GCC optimize("Ofast") #pragma GCC target("avx2") #define MD 1000000007 int inverse(int a){ int b=MD; int u=1; int v=0; int s,t; while(b){ t=a/b; s=b; b=a-t*b; a=s; s=v; v=u-t*v; u=s; } if(u<0){ u+=MD; } return u; } int fact(int n){ long z=1; while(n){ z=(z*n--)%MD; } return z; } main(){ char rbuf[16]; read(0,rbuf,sizeof rbuf); char*rp=rbuf; int n=0; int c; while(c=*rp++-48,c>=0){ n=n*10+c; if(n>MD){ puts("0"); exit(0); } } --n; int f=n<MD/2?n&1?MD-fact(n):fact(n):MD-inverse(fact(MD-1-n)); printf("%d\n",f); }