結果

問題 No.982 Add
ユーザー uni_python
提出日時 2020-08-11 23:26:33
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 47 ms / 2,000 ms
コード長 545 bytes
コンパイル時間 350 ms
コンパイル使用メモリ 82,260 KB
実行使用メモリ 59,264 KB
最終ジャッジ日時 2024-10-09 11:55:28
合計ジャッジ時間 2,275 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=sys.stdin.readline
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    import math
    
    a,b=MI()
    if min(a,b)==1:
        print(0)
        exit()
    
    if math.gcd(a,b)!=1:
        print(-1)
    else:
        S=set([])
        M=a*b
        for i in range(101):
            for j in range(101):
                temp=a*i + b*j
                if temp<M:
                   S.add(temp)
        print(M-len(S))


main()
0