結果
問題 | No.101 ぐるぐる!あみだくじ! |
ユーザー | testestest |
提出日時 | 2015-12-06 14:11:25 |
言語 | C90 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 494 bytes |
コンパイル時間 | 734 ms |
コンパイル使用メモリ | 24,556 KB |
実行使用メモリ | 4,500 KB |
最終ジャッジ日時 | 2023-10-12 16:41:23 |
合計ジャッジ時間 | 2,281 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
4,348 KB |
testcase_01 | AC | 1 ms
4,352 KB |
testcase_02 | AC | 0 ms
4,352 KB |
testcase_03 | AC | 1 ms
4,352 KB |
testcase_04 | WA | - |
testcase_05 | AC | 0 ms
4,352 KB |
testcase_06 | AC | 1 ms
4,352 KB |
testcase_07 | AC | 1 ms
4,348 KB |
testcase_08 | AC | 1 ms
4,376 KB |
testcase_09 | AC | 1 ms
4,352 KB |
testcase_10 | AC | 0 ms
4,352 KB |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | AC | 0 ms
4,352 KB |
testcase_35 | AC | 0 ms
4,352 KB |
testcase_36 | AC | 1 ms
4,356 KB |
testcase_37 | AC | 1 ms
4,352 KB |
testcase_38 | AC | 1 ms
4,352 KB |
testcase_39 | AC | 1 ms
4,356 KB |
コンパイルメッセージ
main.c:1:1: warning: data definition has no type or storage class num[10];count; ^~~ main.c:1:1: warning: type defaults to ‘int’ in declaration of ‘num’ [-Wimplicit-int] main.c:1:9: warning: data definition has no type or storage class num[10];count; ^~~~~ main.c:1:9: warning: type defaults to ‘int’ in declaration of ‘count’ [-Wimplicit-int] main.c:2:1: warning: data definition has no type or storage class check[101]; ^~~~~ main.c:2:1: warning: type defaults to ‘int’ in declaration of ‘check’ [-Wimplicit-int] main.c:3:1: warning: data definition has no type or storage class x[1000];y[1000]; ^ main.c:3:1: warning: type defaults to ‘int’ in declaration of ‘x’ [-Wimplicit-int] main.c:3:9: warning: data definition has no type or storage class x[1000];y[1000]; ^ main.c:3:9: warning: type defaults to ‘int’ in declaration of ‘y’ [-Wimplicit-int] main.c:5:1: warning: return type defaults to ‘int’ [-Wimplicit-int] gcd(a,b){return b?gcd(b,a%b):a;} ^~~ main.c: In function ‘gcd’: main.c:5:1: warning: type of ‘a’ defaults to ‘int’ [-Wimplicit-int] main.c:5:1: warning: type of ‘b’ defaults to ‘int’ [-Wimplicit-int] main.c: At top level: main.c:7:1: warning: return type defaults to ‘int’ [-Wimplicit-int] lcm(int*a){ ^~~ main.c:13:1: warning: return type defaults to ‘int’ [-Wimplicit-int] main(){ ^~~~ main.c: In function ‘main’: main.c:15:1: warning: implicit declaration of function ‘scanf’ [-Wimplicit-function-declaration] scanf("%d%d",&n,&k); ^~~~~ main.c:15:1: warning: incompatible implicit declaration of built-in function ‘scanf’ main.c:15:1: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’ main.c:1:1: +#include <stdio.h> num[10];count; main.c:15:1: scanf("%d%d",&n,&k); ^~~~~ main.c:31:1: warning: implicit declaration of function ‘printf’ [-Wimplicit-function-declaration] printf("%d",lcm(num)); ^~~~~~ main.c:31:1: warning: incompati
ソースコード
num[10];count; check[101]; x[1000];y[1000]; gcd(a,b){return b?gcd(b,a%b):a;} lcm(int*a){ if(a[1]==0)return *a; a[1]*=*a/gcd(*a,a[1]); return lcm(a+1); } main(){ int n,k,i,j,temp,times; scanf("%d%d",&n,&k); for(i=0;i<k;i++)scanf("%d%d",x+i,y+i); for(i=1;i<=n;i++){ if(check[i]++)continue; temp=i; times=0; do{ for(j=0;j<k;j++){ if(x[j]==temp)temp=y[j]; else if(y[j]==temp)temp=x[j]; } times++; check[temp]++; }while(temp!=i); num[count++]=times; } printf("%d",lcm(num)); }