結果

問題 No.816 Beautiful tuples
コンテスト
ユーザー yurara
提出日時 2019-06-09 14:05:54
言語 Python3
(3.14.7 + numpy 2.5.2 + scipy 1.18.0 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
AC  
実行時間 23 ms / 1,500 ms
+ 381µs
コード長 425 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 55 ms
コンパイル使用メモリ 14,848 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2026-10-12 19:20:13
合計ジャッジ時間 1,679 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge3_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import math

def divisors(n):
    lst = []
    for i in range(1, int(math.sqrt(n)) + 1):
        if n % i == 0:
            lst.append(i)
            if i != n // i:
                lst.append(n // i)
    lst.sort()
    return lst

A, B = map(int, input().split())

for d in filter(lambda x: x != A and x != B, divisors(A + B)):
    if (A + d) % B == 0 and (B + d) % A == 0:
        print(d)
        break
else:
    print(-1)
0