結果
問題 |
No.990 N×Mマス計算(Kの倍数)
|
ユーザー |
![]() |
提出日時 | 2020-02-14 22:44:02 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 710 bytes |
コンパイル時間 | 372 ms |
コンパイル使用メモリ | 82,848 KB |
実行使用メモリ | 96,532 KB |
最終ジャッジ日時 | 2024-11-16 01:05:51 |
合計ジャッジ時間 | 8,043 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 17 TLE * 2 |
ソースコード
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) c = Counter() for a in A: for d in ds: if a%d==0: c[d] += 1 break for b in B: for d in ds: if (b*d)%K == 0: ans += c[d] print(ans)