結果

問題 No.982 Add
ユーザー ryo_n
提出日時 2020-02-14 20:49:15
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
WA  
実行時間 -
コード長 508 bytes
コンパイル時間 178 ms
コンパイル使用メモリ 12,800 KB
実行使用メモリ 10,880 KB
最終ジャッジ日時 2024-10-06 09:49:20
合計ジャッジ時間 1,638 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #



A, B = [int(x) for x in input().split()]

A, B = min(A, B), max(A, B)

if A == 1 or B == 1:
    print(0)
    exit()


for i in range(2, 101):
    if A % i == 0 and B % i == 0:
        print(-1)
        exit()


x = set()

j = 1
while len(x) != B:
    x.add((j * A) % B)
    j += 1

ans = 0
for i in range(j * A):
    if (i % A) % B == 0:
        pass
    elif i % A == 0:
        pass
    elif i % B == 0:
        pass
    elif (i % B) % A == 0:
        pass
    else:
        ans += 1

print(ans // 2)


0