結果
| 問題 | 
                            No.990 N×Mマス計算(Kの倍数)
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2020-02-14 23:28:23 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                TLE
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 513 bytes | 
| コンパイル時間 | 173 ms | 
| コンパイル使用メモリ | 12,416 KB | 
| 実行使用メモリ | 57,168 KB | 
| 最終ジャッジ日時 | 2024-11-16 01:41:33 | 
| 合計ジャッジ時間 | 17,895 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge3 / judge1 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 14 TLE * 5 | 
ソースコード
import math
from collections import Counter
n, m, k = map(int, input().split())
line = input().split()
op = line[0]
B = list(map(int, line[1:]))
A = [int(input()) for _ in range(n)]
if op == '+':
    mod = [a % k for a in A]
    modcnt = Counter(mod)
    ans = sum([modcnt[(k - (b%k)) % k] for b in B])
else:
    gcda = [math.gcd(k,a) for a in A]
    gcdb = [math.gcd(k,b) for b in B]
    ans = 0
    for ga in gcda:
        for gb in gcdb:
            if (ga * gb) % k == 0:
                ans += 1
print(ans)