結果
問題 | No.990 N×Mマス計算(Kの倍数) |
ユーザー | prd_xxx |
提出日時 | 2020-02-14 22:54:32 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 868 bytes |
コンパイル時間 | 109 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 32,936 KB |
最終ジャッジ日時 | 2024-04-27 20:04:19 |
合計ジャッジ時間 | 4,352 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 26 ms
17,696 KB |
testcase_01 | AC | 24 ms
10,752 KB |
testcase_02 | AC | 24 ms
10,880 KB |
testcase_03 | AC | 25 ms
11,008 KB |
testcase_04 | AC | 25 ms
11,008 KB |
testcase_05 | AC | 25 ms
10,624 KB |
testcase_06 | AC | 27 ms
10,880 KB |
testcase_07 | AC | 27 ms
10,752 KB |
testcase_08 | AC | 26 ms
10,880 KB |
testcase_09 | AC | 25 ms
10,752 KB |
testcase_10 | AC | 117 ms
17,000 KB |
testcase_11 | AC | 145 ms
19,808 KB |
testcase_12 | TLE | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
ソースコード
import sys input = sys.stdin.readline N,M,K = map(int,input().split()) op,*B = input().split() A = [int(input()) for i in range(N)] B = [int(b) for b in B] from collections import Counter ans = 0 if op=='+': c = Counter() for a in A: c[a%K] += 1 for b in B: ans += c[(K-b%K)%K] else: ds = set() m = 1 while m*m <= K: if K%m==0: ds.add(m) ds.add(K//m) m += 1 ds = sorted(list(ds), reverse=True) ca = Counter() for a in A: for d in ds: if a%d==0: ca[d] += 1 break cb = Counter() for b in B: for d in ds: if b%d==0: cb[d] += 1 break for ka,va in ca.items(): for kb,vb in cb.items(): if (ka*kb)%K == 0: ans += va*vb print(ans)