結果

問題 No.990 N×Mマス計算(Kの倍数)
ユーザー ryo_nryo_n
提出日時 2020-02-14 23:20:20
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
RE  
実行時間 -
コード長 524 bytes
コンパイル時間 72 ms
コンパイル使用メモリ 12,544 KB
実行使用メモリ 39,156 KB
最終ジャッジ日時 2024-04-27 20:18:53
合計ジャッジ時間 3,778 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
11,392 KB
testcase_01 RE -
testcase_02 RE -
testcase_03 AC 28 ms
11,392 KB
testcase_04 RE -
testcase_05 AC 30 ms
11,520 KB
testcase_06 AC 28 ms
11,392 KB
testcase_07 RE -
testcase_08 AC 27 ms
11,392 KB
testcase_09 AC 28 ms
11,392 KB
testcase_10 AC 143 ms
22,376 KB
testcase_11 AC 184 ms
21,104 KB
testcase_12 RE -
testcase_13 RE -
testcase_14 AC 266 ms
21,664 KB
testcase_15 AC 203 ms
16,128 KB
testcase_16 AC 223 ms
22,532 KB
testcase_17 AC 141 ms
15,872 KB
testcase_18 RE -
testcase_19 RE -
testcase_20 AC 344 ms
39,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import collections

import fractions

N, M, K = [int(x) for x in input().split()]
C = [x for x in input().split()]
B = [int(x) for x in C[1:]]
A = [int(input()) for _ in range(N)]

B_K = [x % K for x in B]
c_B_K = collections.Counter(B_K)

ans = 0

for j in range(N):
    if C[0] == '+':
        ans += c_B_K[(K - A[j] % K) % K]
    else:
        if A[j] % K == 0:
            ans += M
            continue
        z = (A[j] * K) // fractions.gcd(A[j], K)
        ans += c_B_K[z // A[j]]
        ans += c_B_K[0]

print(ans)
0