結果

問題 No.1201 お菓子配り-4
ユーザー neterukunneterukun
提出日時 2020-08-28 23:12:58
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 3,052 ms / 4,000 ms
コード長 551 bytes
コンパイル時間 297 ms
コンパイル使用メモリ 87,220 KB
実行使用メモリ 77,572 KB
最終ジャッジ日時 2023-08-08 21:38:12
合計ジャッジ時間 22,905 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 135 ms
76,952 KB
testcase_01 AC 778 ms
77,092 KB
testcase_02 AC 1,083 ms
77,336 KB
testcase_03 AC 567 ms
77,376 KB
testcase_04 AC 321 ms
77,164 KB
testcase_05 AC 674 ms
77,444 KB
testcase_06 AC 171 ms
77,184 KB
testcase_07 AC 354 ms
77,384 KB
testcase_08 AC 828 ms
77,324 KB
testcase_09 AC 634 ms
77,036 KB
testcase_10 AC 89 ms
76,548 KB
testcase_11 AC 227 ms
77,572 KB
testcase_12 AC 1,222 ms
77,208 KB
testcase_13 AC 113 ms
76,908 KB
testcase_14 AC 97 ms
76,804 KB
testcase_15 AC 974 ms
77,156 KB
testcase_16 AC 357 ms
77,352 KB
testcase_17 AC 435 ms
77,228 KB
testcase_18 AC 139 ms
77,064 KB
testcase_19 AC 136 ms
76,940 KB
testcase_20 AC 72 ms
71,096 KB
testcase_21 AC 71 ms
71,140 KB
testcase_22 AC 75 ms
71,532 KB
testcase_23 AC 73 ms
71,324 KB
testcase_24 AC 73 ms
71,492 KB
testcase_25 AC 73 ms
71,284 KB
testcase_26 AC 73 ms
71,096 KB
testcase_27 AC 72 ms
71,268 KB
testcase_28 AC 74 ms
71,280 KB
testcase_29 AC 73 ms
70,972 KB
testcase_30 AC 1,520 ms
77,456 KB
testcase_31 AC 1,520 ms
77,380 KB
testcase_32 AC 1,513 ms
77,348 KB
testcase_33 AC 1,517 ms
77,424 KB
testcase_34 AC 1,521 ms
77,372 KB
testcase_35 AC 3,052 ms
77,252 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