結果
問題 |
No.990 N×Mマス計算(Kの倍数)
|
ユーザー |
![]() |
提出日時 | 2020-02-14 22:53:19 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 868 bytes |
コンパイル時間 | 395 ms |
コンパイル使用メモリ | 82,520 KB |
実行使用メモリ | 96,428 KB |
最終ジャッジ日時 | 2024-11-16 01:15:44 |
合計ジャッジ時間 | 9,822 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 16 TLE * 3 |
ソースコード
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)