結果
問題 | No.101 ぐるぐる!あみだくじ! |
ユーザー | 👑 testestest |
提出日時 | 2015-12-06 14:11:25 |
言語 | C90 (gcc 11.4.0) |
結果 |
AC
|
実行時間 | 1 ms / 5,000 ms |
コード長 | 494 bytes |
コンパイル時間 | 395 ms |
コンパイル使用メモリ | 21,120 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-09-14 15:18:53 |
合計ジャッジ時間 | 1,687 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
5,248 KB |
testcase_01 | AC | 1 ms
5,376 KB |
testcase_02 | AC | 1 ms
5,376 KB |
testcase_03 | AC | 0 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 | 1 ms
5,376 KB |
testcase_10 | AC | 1 ms
5,376 KB |
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 |
testcase_17 | AC | 1 ms
5,376 KB |
testcase_18 | AC | 1 ms
5,376 KB |
testcase_19 | AC | 1 ms
5,376 KB |
testcase_20 | AC | 0 ms
5,376 KB |
testcase_21 | AC | 1 ms
5,376 KB |
testcase_22 | AC | 1 ms
5,376 KB |
testcase_23 | AC | 1 ms
5,376 KB |
testcase_24 | AC | 0 ms
5,376 KB |
testcase_25 | AC | 1 ms
5,376 KB |
testcase_26 | AC | 1 ms
5,376 KB |
testcase_27 | AC | 1 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 | 0 ms
5,376 KB |
testcase_33 | AC | 1 ms
5,376 KB |
testcase_34 | AC | 1 ms
5,376 KB |
testcase_35 | AC | 0 ms
5,376 KB |
testcase_36 | AC | 0 ms
5,376 KB |
testcase_37 | AC | 1 ms
5,376 KB |
testcase_38 | AC | 1 ms
5,376 KB |
testcase_39 | AC | 1 ms
5,376 KB |
コンパイルメッセージ
main.c:1:1: warning: data definition has no type or storage class 1 | 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 1 | 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 2 | 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 3 | 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 3 | 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] 5 | 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] 7 | lcm(int*a){ | ^~~ main.c:13:1: warning: return type defaults to ‘int’ [-Wimplicit-int] 13 | main(){ | ^~~~ main.c: In function ‘main’: main.c:15:1: warning: implicit declaration of function ‘scanf’ [-Wimplicit-function-declaration] 15 | scanf("%d%d",&n,&k); | ^~~~~ main.c:1:1: note: include ‘<stdio.h>’ or provide a declaration of ‘scanf’ +++ |+#include <stdio.h> 1 | num[10];count; main.c:15:1: warning: incompatible implicit declaration of built-in function ‘scanf’ [-Wbuiltin-declaration-mismatch] 15 | scanf("%d%d",&n,&k); | ^~~~~ main
ソースコード
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)); }