結果

問題 No.982 Add
ユーザー hedwig100hedwig100
提出日時 2020-04-08 21:59:53
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
AC  
実行時間 22 ms / 2,000 ms
コード長 564 bytes
コンパイル時間 211 ms
コンパイル使用メモリ 10,952 KB
実行使用メモリ 8,452 KB
最終ジャッジ日時 2023-09-26 11:04:24
合計ジャッジ時間 2,621 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,980 KB
testcase_01 AC 16 ms
7,968 KB
testcase_02 AC 16 ms
8,024 KB
testcase_03 AC 16 ms
8,008 KB
testcase_04 AC 16 ms
8,148 KB
testcase_05 AC 18 ms
7,948 KB
testcase_06 AC 17 ms
7,968 KB
testcase_07 AC 17 ms
7,968 KB
testcase_08 AC 16 ms
8,168 KB
testcase_09 AC 19 ms
8,392 KB
testcase_10 AC 19 ms
8,452 KB
testcase_11 AC 17 ms
8,136 KB
testcase_12 AC 17 ms
8,008 KB
testcase_13 AC 17 ms
8,080 KB
testcase_14 AC 17 ms
7,972 KB
testcase_15 AC 17 ms
8,140 KB
testcase_16 AC 18 ms
8,020 KB
testcase_17 AC 18 ms
7,944 KB
testcase_18 AC 16 ms
8,180 KB
testcase_19 AC 17 ms
7,944 KB
testcase_20 AC 17 ms
8,028 KB
testcase_21 AC 17 ms
7,980 KB
testcase_22 AC 17 ms
8,136 KB
testcase_23 AC 17 ms
8,076 KB
testcase_24 AC 21 ms
8,368 KB
testcase_25 AC 22 ms
8,296 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 10 ** 9 + 7
INF = 10 ** 10
import sys
input = sys.stdin.readline
sys.setrecursionlimit(100000000)
dy = (-1,0,1,0)
dx = (0,1,0,-1)
from bisect import bisect_left,bisect_right
from math import gcd

def main():
    a,b = map(int,input().split())
    n = gcd(a,b)
    if n > 1:
        print(-1)
        return

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

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