結果

問題 No.816 Beautiful tuples
ユーザー titiatitia
提出日時 2019-04-19 21:30:19
言語 Python3
(3.11.2 + numpy 1.24.2 + scipy 1.10.1)
結果
AC  
実行時間 21 ms / 1,500 ms
コード長 312 bytes
コンパイル時間 669 ms
実行使用メモリ 7,932 KB
最終ジャッジ日時 2023-03-31 11:40:07
合計ジャッジ時間 1,777 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,780 KB
testcase_01 AC 15 ms
7,836 KB
testcase_02 AC 16 ms
7,732 KB
testcase_03 AC 16 ms
7,836 KB
testcase_04 AC 16 ms
7,692 KB
testcase_05 AC 21 ms
7,648 KB
testcase_06 AC 16 ms
7,832 KB
testcase_07 AC 16 ms
7,824 KB
testcase_08 AC 16 ms
7,820 KB
testcase_09 AC 16 ms
7,784 KB
testcase_10 AC 17 ms
7,772 KB
testcase_11 AC 18 ms
7,820 KB
testcase_12 AC 19 ms
7,932 KB
testcase_13 AC 18 ms
7,784 KB
testcase_14 AC 15 ms
7,888 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

A,B=map(int,input().split())
x=A+B
import math
xr=math.ceil(math.sqrt(x))

LIST=[]
for i in range(1,xr+1):
    if x%i==0:
        LIST.append(i)
        LIST.append(x//i)

LIST.sort()

for l in LIST:
    if (A+l)%B==0 and (B+l)%A==0 and A!=l and B!=l and A!=B:
        print(l)
        break
else:
    print(-1)
0