結果
問題 | No.990 N×Mマス計算(Kの倍数) |
ユーザー | brthyyjp |
提出日時 | 2020-02-14 22:13:52 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,039 bytes |
コンパイル時間 | 134 ms |
コンパイル使用メモリ | 82,444 KB |
実行使用メモリ | 119,468 KB |
最終ジャッジ日時 | 2024-04-27 19:43:40 |
合計ジャッジ時間 | 4,398 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 32 ms
59,892 KB |
testcase_01 | AC | 32 ms
52,884 KB |
testcase_02 | AC | 37 ms
60,860 KB |
testcase_03 | AC | 33 ms
53,360 KB |
testcase_04 | AC | 32 ms
53,564 KB |
testcase_05 | AC | 33 ms
53,304 KB |
testcase_06 | AC | 31 ms
52,800 KB |
testcase_07 | AC | 37 ms
59,348 KB |
testcase_08 | AC | 35 ms
52,196 KB |
testcase_09 | AC | 34 ms
54,064 KB |
testcase_10 | AC | 94 ms
88,116 KB |
testcase_11 | AC | 101 ms
94,276 KB |
testcase_12 | TLE | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
ソースコード
n, m, k = map(int, input().split()) l = list(map(str, input().split())) b = [int(l[i]) for i in range(1, m+1)] op = l[0] #print(op) #rint(b) a = [0]*n for i in range(n): a[i] = int(input()) da = {} for i in range(n): if a[i]%k not in da: da[a[i]%k] = 1 else: da[a[i]%k] += 1 db = {} for i in range(m): if b[i]%k not in db: db[b[i]%k] = 1 else: db[b[i]%k] += 1 #print(da) #print(db) if op == '+': ans = 0 for i in da: if i == 0: j = 0 else: j = k-i if j in db: ans += da[i]*db[j] else: ans = 0 for i in da: if i == 0: continue for j in db: if j == 0: continue if (i * j)%k == 0: ans += da[i]*db[j] if 0 in da and 0 in db: ans += da[0]*m + db[0]*n - da[0]*db[0] elif 0 in da and 0 not in db: ans += da[0]*m elif 0 not in da and 0 in db: ans += db[0]*n else: pass print(ans)