結果

問題 No.982 Add
コンテスト
ユーザー ryo_n
提出日時 2020-02-14 20:49:15
言語 Python3
(3.15.0 + numpy 2.5.4 + scipy 1.18.1 + ACL)
コンパイル:
python3 -mpy_compile _filename_
実行:
python3 _filename_
結果
WA  
実行時間 -
コード長 508 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 58 ms
コンパイル使用メモリ 15,232 KB
実行使用メモリ 11,008 KB
最終ジャッジ日時 2026-09-11 01:26:35
合計ジャッジ時間 2,243 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 17 WA * 6
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code



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