結果
問題 |
No.990 N×Mマス計算(Kの倍数)
|
ユーザー |
![]() |
提出日時 | 2020-02-15 13:25:00 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 469 ms / 2,000 ms |
コード長 | 490 bytes |
コンパイル時間 | 161 ms |
コンパイル使用メモリ | 12,672 KB |
実行使用メモリ | 40,984 KB |
最終ジャッジ日時 | 2024-11-16 02:10:46 |
合計ジャッジ時間 | 3,657 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 19 |
ソースコード
import sys, math from itertools import groupby, product n, m, k = map(int, input().split()) op, *B = input().split() def c(it): return [(i, len(list(u))) for i, u in groupby(sorted(it))] if op=="+": s = sorted(c(int(a)%k for a in sys.stdin) + c(-int(b)%k for b in B)) print(sum(u*v for (i, u), (j, v) in zip(s, s[1:]) if i==j)) else: s = product( c(math.gcd(int(a), k) for a in sys.stdin), c(math.gcd(int(b), k) for b in B)) print(sum(u*v for (i, u), (j, v) in s if i*j%k==0))