結果

問題 No.1201 お菓子配り-4
ユーザー neterukunneterukun
提出日時 2020-08-28 23:12:58
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 2,960 ms / 4,000 ms
コード長 551 bytes
コンパイル時間 338 ms
コンパイル使用メモリ 81,968 KB
実行使用メモリ 76,440 KB
最終ジャッジ日時 2024-04-26 13:52:26
合計ジャッジ時間 20,871 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 103 ms
75,636 KB
testcase_01 AC 731 ms
76,136 KB
testcase_02 AC 1,018 ms
76,092 KB
testcase_03 AC 516 ms
75,796 KB
testcase_04 AC 283 ms
76,124 KB
testcase_05 AC 630 ms
76,036 KB
testcase_06 AC 137 ms
75,700 KB
testcase_07 AC 314 ms
76,416 KB
testcase_08 AC 778 ms
76,440 KB
testcase_09 AC 581 ms
76,232 KB
testcase_10 AC 54 ms
71,024 KB
testcase_11 AC 191 ms
76,020 KB
testcase_12 AC 1,168 ms
76,152 KB
testcase_13 AC 83 ms
75,868 KB
testcase_14 AC 65 ms
75,884 KB
testcase_15 AC 937 ms
76,312 KB
testcase_16 AC 323 ms
75,988 KB
testcase_17 AC 394 ms
75,808 KB
testcase_18 AC 104 ms
75,948 KB
testcase_19 AC 104 ms
75,904 KB
testcase_20 AC 37 ms
52,708 KB
testcase_21 AC 36 ms
53,336 KB
testcase_22 AC 36 ms
52,444 KB
testcase_23 AC 35 ms
53,508 KB
testcase_24 AC 36 ms
52,572 KB
testcase_25 AC 36 ms
53,256 KB
testcase_26 AC 36 ms
52,288 KB
testcase_27 AC 37 ms
52,688 KB
testcase_28 AC 36 ms
53,412 KB
testcase_29 AC 36 ms
52,744 KB
testcase_30 AC 1,449 ms
76,096 KB
testcase_31 AC 1,457 ms
76,036 KB
testcase_32 AC 1,448 ms
76,096 KB
testcase_33 AC 1,464 ms
76,172 KB
testcase_34 AC 1,478 ms
76,144 KB
testcase_35 AC 2,960 ms
76,224 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def gcd(a: int, b: int) -> int:
    """a, bの最大公約数(greatest common divisor: GCD)を求める
    計算量: O(log(min(a, b)))
    """
    while b:
        a, b = b, a % b
    return a


n = int(input())
m = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
MOD = 10 ** 9 + 7


ans = 0
for i in range(n):
    a_val = a[i]
    for j in range(m):
        b_val = b[j]
        gcd_ = gcd(a_val, b_val)
        ans += gcd_ + (a_val - 1) * (b_val - 1) - 1
        ans += 2 * a_val
        ans %= MOD

print(ans)
0