結果

問題 No.982 Add
ユーザー stng
提出日時 2022-08-15 20:21:42
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 45 ms / 2,000 ms
コード長 329 bytes
コンパイル時間 370 ms
コンパイル使用メモリ 82,168 KB
実行使用メモリ 61,868 KB
最終ジャッジ日時 2024-10-02 08:43:26
合計ジャッジ時間 2,154 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

import math
a,b = map(int,input().split())
gd = math.gcd(a,b)
if gd != 1:
    print(-1)
    exit()

li = [0]*(a*b+1)
for i in range(a+1):
    for j in range(b+1):
        tmp = b*i+a*j
        if tmp <= a*b:
            li[tmp] = 1
        
#print(li)
ans = 0
for i in range(a*b+1):
    if li[i] == 0:
        ans += 1
print(ans)
0