結果
問題 | No.990 N×Mマス計算(Kの倍数) |
ユーザー | ayaoni |
提出日時 | 2020-11-24 18:16:40 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,143 bytes |
コンパイル時間 | 489 ms |
コンパイル使用メモリ | 81,792 KB |
実行使用メモリ | 94,976 KB |
最終ジャッジ日時 | 2024-07-23 18:43:07 |
合計ジャッジ時間 | 4,901 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
57,856 KB |
testcase_01 | AC | 39 ms
52,352 KB |
testcase_02 | AC | 39 ms
52,352 KB |
testcase_03 | AC | 40 ms
52,096 KB |
testcase_04 | AC | 46 ms
59,264 KB |
testcase_05 | AC | 42 ms
52,480 KB |
testcase_06 | AC | 41 ms
52,096 KB |
testcase_07 | AC | 41 ms
52,864 KB |
testcase_08 | AC | 40 ms
52,224 KB |
testcase_09 | AC | 41 ms
52,224 KB |
testcase_10 | AC | 98 ms
86,548 KB |
testcase_11 | AC | 102 ms
87,552 KB |
testcase_12 | TLE | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
ソースコード
import sys from math import gcd def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LS(): return list(sys.stdin.readline().rstrip().split()) N,M,K = MI() X = LS() op = X[0] B = [int(X[i]) for i in range(1,M+1)] A = [I() for _ in range(N)] if op == '+': count_A = {} count_B = {} for i in range(N): a = A[i] % K if a in count_A.keys(): count_A[a] += 1 else: count_A[a] = 1 for i in range(M): b = B[i] % K if b in count_B.keys(): count_B[b] += 1 else: count_B[b] = 1 ans = 0 for i in count_A.keys(): j = (K-i) % K if j in count_B.keys(): ans += count_A[i]*count_B[j] else: div = [] for i in range(1,int(K**.5)+1): if K % i == 0: div.append(i) if i != K//i: div.append(K//i) count_A = {} for d in div: r = sum(A[i] % d == 0 for i in range(N)) count_A[d] = r ans = 0 for b in B: r = K//gcd(K,b) ans += count_A[r] print(ans)