結果

問題 No.982 Add
コンテスト
ユーザー 👑 SPD_9X2
提出日時 2025-10-25 20:06:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 53 ms / 2,000 ms
コード長 264 bytes
コンパイル時間 375 ms
コンパイル使用メモリ 82,384 KB
実行使用メモリ 68,332 KB
最終ジャッジ日時 2025-10-25 20:06:34
合計ジャッジ時間 3,144 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

A,B = map(int,input().split())

dp = [0] * (10**6)
dp[0] = 1

for i in range(len(dp)):

    if i+A < len(dp):
        dp[i+A] |= dp[i]
    if i+B < len(dp):
        dp[i+B] |= dp[i]


ans = len(dp) - sum(dp)

if ans >= 10**5:
    print (-1)
else:
    print (ans)
0