結果
問題 | No.816 Beautiful tuples |
ユーザー | tails |
提出日時 | 2019-04-19 22:43:44 |
言語 | C (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 1 ms / 1,500 ms |
コード長 | 267 bytes |
コンパイル時間 | 307 ms |
コンパイル使用メモリ | 29,696 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-22 22:59:43 |
合計ジャッジ時間 | 860 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 1 ms
6,816 KB |
testcase_01 | AC | 1 ms
6,940 KB |
testcase_02 | AC | 1 ms
6,944 KB |
testcase_03 | AC | 1 ms
6,940 KB |
testcase_04 | AC | 1 ms
6,940 KB |
testcase_05 | AC | 1 ms
6,944 KB |
testcase_06 | AC | 1 ms
6,940 KB |
testcase_07 | AC | 1 ms
6,940 KB |
testcase_08 | AC | 1 ms
6,940 KB |
testcase_09 | AC | 1 ms
6,940 KB |
testcase_10 | AC | 1 ms
6,940 KB |
testcase_11 | AC | 1 ms
6,944 KB |
testcase_12 | AC | 1 ms
6,940 KB |
testcase_13 | AC | 1 ms
6,940 KB |
testcase_14 | AC | 1 ms
6,944 KB |
コンパイルメッセージ
main.c:1:1: warning: data definition has no type or storage class 1 | a,b,c,d,r; | ^ main.c:1:1: warning: type defaults to 'int' in declaration of 'a' [-Wimplicit-int] main.c:1:3: warning: type defaults to 'int' in declaration of 'b' [-Wimplicit-int] 1 | a,b,c,d,r; | ^ main.c:1:5: warning: type defaults to 'int' in declaration of 'c' [-Wimplicit-int] 1 | a,b,c,d,r; | ^ main.c:1:7: warning: type defaults to 'int' in declaration of 'd' [-Wimplicit-int] 1 | a,b,c,d,r; | ^ main.c:1:9: warning: type defaults to 'int' in declaration of 'r' [-Wimplicit-int] 1 | a,b,c,d,r; | ^ main.c:2:1: warning: return type defaults to 'int' [-Wimplicit-int] 2 | f(x){ | ^ main.c: In function 'f': main.c:2:1: warning: type of 'x' defaults to 'int' [-Wimplicit-int] main.c: At top level: main.c:5:1: warning: return type defaults to 'int' [-Wimplicit-int] 5 | main(){ | ^~~~ main.c: In function 'main': main.c:7:9: warning: implicit declaration of function 'scanf' [-Wimplicit-function-declaration] 7 | scanf("%d%d",&a,&b); | ^~~~~ main.c:1:1: note: include '<stdio.h>' or provide a declaration of 'scanf' +++ |+#include <stdio.h> 1 | a,b,c,d,r; main.c:7:9: warning: incompatible implicit declaration of built-in function 'scanf' [-Wbuiltin-declaration-mismatch] 7 | scanf("%d%d",&a,&b); | ^~~~~ main.c:7:9: note: include '<stdio.h>' or provide a declaration of 'scanf' main.c:8:11: warning: implicit declaration of function 'sqrt' [-Wimplicit-function-declaration] 8 | d=sqrt(a+b); | ^~~~ main.c:1:1: note: include '<math.h>' or provide a declaration of 'sqrt' +++ |+#include <math.h> 1 | a,b,c,d,r; main.c:8:11: warning: incompatible implicit declaration of built-in function 'sqrt' [-Wbuiltin-declaration-mismatch] 8 | d=sqrt(a+b); | ^~~~ main.c:8:11: note: include '<math.h>' or provide a declaration
ソースコード
a,b,c,d,r; f(x){ return x!=a&&x!=b&&(a+x)%b==0&&(b+x)%a==0; } main(){ r=-1; scanf("%d%d",&a,&b); d=sqrt(a+b); for(c=1;c<=d;++c){ if((a+b)%c==0){ if(f(c)){ printf("%d",c); exit(0); } if(f((a+b)/c)){ r=(a+b)/c; } } } printf("%d",r); }