QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#734161 | #7797. Based Zeros | kivi_gab | WA | 17ms | 10700kb | Python3 | 1.0kb | 2024-11-11 02:28:29 | 2024-11-11 02:28:29 |
Judging History
answer
import math
def count_trailing_zeros_in_base(n, base):
count = 0
while n % base == 0:
n //= base
count += 1
return count
def find_optimal_bases(n):
max_zeros = 0
best_bases = []
for i in range(1, int(math.sqrt(n)) + 1):
if n % i == 0:
for base in [i, n // i]:
if base > 1:
zeros = count_trailing_zeros_in_base(n, base)
if zeros > max_zeros:
max_zeros = zeros
best_bases = [base]
elif zeros == max_zeros:
best_bases.append(base)
best_bases.sort()
return max_zeros, best_bases
results = []
for _ in range(int(input())):
n = int(input("Enter n: "))
max_zeros, bases = find_optimal_bases(n)
results.append((max_zeros, len(bases), bases))
for result in results:
max_zeros, m, bases = result
print(max_zeros, m)
print(" ".join(map(str, bases)))
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 17ms
memory: 10700kb
input:
3 11 1007 239
output:
Enter n: Enter n: Enter n: 1 1 11 1 3 19 53 1007 1 1 239
result:
wrong output format Expected integer, but "Enter" found