結果
問題 | No.990 N×Mマス計算(Kの倍数) |
ユーザー | vwxyz |
提出日時 | 2023-07-15 04:56:06 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 874 bytes |
コンパイル時間 | 1,010 ms |
コンパイル使用メモリ | 87,228 KB |
実行使用メモリ | 113,340 KB |
最終ジャッジ日時 | 2023-10-14 19:29:46 |
合計ジャッジ時間 | 13,351 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge14 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 98 ms
71,552 KB |
testcase_01 | AC | 97 ms
71,864 KB |
testcase_02 | AC | 98 ms
71,604 KB |
testcase_03 | AC | 96 ms
71,548 KB |
testcase_04 | AC | 101 ms
76,776 KB |
testcase_05 | AC | 96 ms
71,808 KB |
testcase_06 | AC | 97 ms
71,576 KB |
testcase_07 | AC | 95 ms
71,696 KB |
testcase_08 | AC | 94 ms
71,540 KB |
testcase_09 | AC | 95 ms
71,600 KB |
testcase_10 | AC | 160 ms
89,400 KB |
testcase_11 | AC | 143 ms
88,956 KB |
testcase_12 | TLE | - |
testcase_13 | AC | 136 ms
85,712 KB |
testcase_14 | AC | 145 ms
86,072 KB |
testcase_15 | AC | 131 ms
81,576 KB |
testcase_16 | AC | 160 ms
91,556 KB |
testcase_17 | AC | 124 ms
81,644 KB |
testcase_18 | TLE | - |
testcase_19 | AC | 1,584 ms
84,196 KB |
testcase_20 | AC | 209 ms
113,340 KB |
ソースコード
import sys readline=sys.stdin.readline from collections import defaultdict from math import gcd as GCD def Divisors(N): divisors=[] for i in range(1,N+1): if i**2>=N: break elif N%i==0: divisors.append(i) if i**2==N: divisors+=[i]+[N//i for i in divisors[::-1]] else: divisors+=[N//i for i in divisors[::-1]] return divisors N,M,K=map(int,readline().split()) op,*B=readline().split() for m in range(M): B[m]=int(B[m]) A=[int(readline()) for n in range(N)] if op=="+": cnt=defaultdict(int) for b in B: cnt[b%K]+=1 ans=0 for a in A: ans+=cnt[(-a)%K] else: cnt=defaultdict(int) D=Divisors(K) for b in B: for d in D: if b%d==0: cnt[d]+=1 ans=0 for a in A: g=GCD(a,K) ans+=cnt[K//g] print(ans)