結果
問題 | No.990 N×Mマス計算(Kの倍数) |
ユーザー | titia |
提出日時 | 2020-02-14 23:07:02 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,130 bytes |
コンパイル時間 | 213 ms |
コンパイル使用メモリ | 81,844 KB |
実行使用メモリ | 98,384 KB |
最終ジャッジ日時 | 2024-04-27 20:10:09 |
合計ジャッジ時間 | 4,572 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 36 ms
62,708 KB |
testcase_01 | AC | 40 ms
55,828 KB |
testcase_02 | AC | 39 ms
55,116 KB |
testcase_03 | AC | 40 ms
54,592 KB |
testcase_04 | AC | 45 ms
61,432 KB |
testcase_05 | AC | 40 ms
54,792 KB |
testcase_06 | AC | 39 ms
54,944 KB |
testcase_07 | AC | 42 ms
55,040 KB |
testcase_08 | AC | 38 ms
54,412 KB |
testcase_09 | AC | 35 ms
55,460 KB |
testcase_10 | AC | 83 ms
91,600 KB |
testcase_11 | AC | 89 ms
87,604 KB |
testcase_12 | TLE | - |
testcase_13 | -- | - |
testcase_14 | -- | - |
testcase_15 | -- | - |
testcase_16 | -- | - |
testcase_17 | -- | - |
testcase_18 | -- | - |
testcase_19 | -- | - |
testcase_20 | -- | - |
ソースコード
import sys from collections import Counter from math import sqrt input = sys.stdin.readline N,M,K=map(int,input().split()) B=list(input().split()) A=[int(input()) for i in range(N)] ANS=0 if B[0]=="+": B=list(map(int,B[1:])) A=Counter([a%K for a in A]) B=Counter([b%K for b in B]) for c in A: ANS+=A[c]*B[K-c] print(ANS) sys.exit() B=list(map(int,B[1:])) x=K L=int(sqrt(x)) FACT=Counter() for i in range(2,L+2): while x%i==0: FACT[i]+=1 x=x//i if x!=1: FACT[x]=FACT.get(x,0)+1 fs=list(FACT.keys()) fv=list(FACT.values()) LEN=len(fs) SCA=Counter() SCB=Counter() for b in B: sc=[0]*LEN for i in range(LEN): f=fs[i] while b%f==0: sc[i]+=1 b//=f SCB[tuple(sc)]+=1 for a in A: sc=[0]*LEN for i in range(LEN): f=fs[i] while a%f==0: sc[i]+=1 a//=f SCA[tuple(sc)]+=1 def geq(sa,sb): for i in range(LEN): if fv[i]-sa[i]>sb[i]: return 0 return SCA[sa]*SCB[sb] for sa in SCA: for sb in SCB: ANS+=geq(sa,sb) print(ANS)