結果
| 問題 |
No.990 N×Mマス計算(Kの倍数)
|
| コンテスト | |
| ユーザー |
qqqqq
|
| 提出日時 | 2020-02-14 21:41:12 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 876 bytes |
| コンパイル時間 | 417 ms |
| コンパイル使用メモリ | 82,144 KB |
| 実行使用メモリ | 109,756 KB |
| 最終ジャッジ日時 | 2024-11-16 00:29:55 |
| 合計ジャッジ時間 | 9,296 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 17 TLE * 2 |
ソースコード
import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
n,m,k = map(int, input().split())
op, *B = input().split()
B = list(map(int, B))
A = [int(input()) for i in range(n)]
from collections import defaultdict
from math import gcd
def divisor(n):
ret = []
for i in range(1,int(n**0.5)+1):
if n%i == 0:
ret.append(i)
if i**2 == n:
continue
ret.append(n//i)
return ret
if op == "+":
d = defaultdict(int)
for bi in B:
d[bi%k] += 1
ans = 0
for ai in A:
target = (-ai)%k
ans += d[target]
else:
divisors = divisor(k)
d = defaultdict(int)
for bi in B:
for ki in divisors:
if bi%ki == 0:
d[ki] += 1
ans = 0
for ai in A:
target = k // gcd(k, ai)
ans += d[target]
print(ans)
qqqqq