結果
問題 | No.1330 Multiply or Divide |
ユーザー | U S |
提出日時 | 2021-01-08 22:25:29 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,164 bytes |
コンパイル時間 | 133 ms |
コンパイル使用メモリ | 81,956 KB |
実行使用メモリ | 117,452 KB |
最終ジャッジ日時 | 2024-04-28 03:46:20 |
合計ジャッジ時間 | 5,704 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 154 ms
112,140 KB |
testcase_02 | WA | - |
testcase_03 | AC | 45 ms
61,144 KB |
testcase_04 | AC | 44 ms
61,136 KB |
testcase_05 | AC | 45 ms
60,516 KB |
testcase_06 | AC | 80 ms
102,200 KB |
testcase_07 | AC | 129 ms
112,428 KB |
testcase_08 | AC | 148 ms
117,052 KB |
testcase_09 | AC | 151 ms
116,776 KB |
testcase_10 | AC | 150 ms
116,664 KB |
testcase_11 | AC | 153 ms
117,044 KB |
testcase_12 | AC | 149 ms
116,980 KB |
testcase_13 | AC | 46 ms
60,900 KB |
testcase_14 | AC | 46 ms
60,288 KB |
testcase_15 | AC | 44 ms
60,348 KB |
testcase_16 | AC | 46 ms
60,248 KB |
testcase_17 | AC | 48 ms
61,056 KB |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 125 ms
117,452 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 44 ms
60,288 KB |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | AC | 46 ms
60,800 KB |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | AC | 103 ms
105,272 KB |
testcase_45 | AC | 103 ms
105,124 KB |
ソースコード
# import sys # input = sys.stdin.readline def mp():return map(int,input().split()) def lmp():return list(map(int,input().split())) import math import bisect from copy import deepcopy as dc from itertools import accumulate from collections import Counter, defaultdict, deque def ceil(U,V):return (U+V-1)//V def modf1(N,MOD):return (N-1)%MOD+1 n,m,p = mp() a = lmp() m = ceil(m+1,max(a)) ag = [] for i in range(n): if math.gcd(a[i], p) == 1 and a[i] != 1: ag.append((a[i],1)) else: cnt = 0 while True: if a[i] % p == 0: cnt += 1 a[i] //= p else: break if a[i] != 1: ag.append((a[i],1+cnt)) if not ag: print(-1) exit() d = defaultdict(lambda:0) for i in range(len(ag)): d[ag[i][1]] = max(d[ag[i][1]], ag[i][0]) d = list(d.items()) # 操作回数 かける数 stack = [(1,1)] #今の数 操作回数 ans = int(1e10) #print(d) while stack: now = stack.pop() if now[0] > m: ans = min(ans,now[1]) #print(now) else: for i,j in d: stack.append((now[0]*j, now[1]+i)) print(ans)