結果

問題 No.982 Add
ユーザー tamatotamato
提出日時 2020-02-11 13:39:34
言語 PyPy3
(7.3.15)
結果
RE  
(最新)
AC  
(最初)
実行時間 -
コード長 398 bytes
コンパイル時間 189 ms
コンパイル使用メモリ 82,460 KB
実行使用メモリ 89,024 KB
最終ジャッジ日時 2024-10-01 07:22:47
合計ジャッジ時間 4,948 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 3
other RE * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

def main():
    import sys
    from fractions import gcd
    input = sys.stdin.readline

    a, b = map(int, input().split())

    if gcd(a, b) != 1:
        print(-1)
        exit()

    ans = [1] * (a*b+1)
    for x in range(b+1):
        for y in range(a+1):
            n = a*x+b*y
            if n <= a*b:
                ans[n] = 0
    print(sum(ans))


if __name__ == '__main__':
    main()
0