QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#734155#7797. Based Zeroskivi_gabTL 110ms10704kbPython3932b2024-11-11 02:24:122024-11-11 02:24:14

Judging History

你现在查看的是最新测评结果

  • [2024-11-11 02:24:14]
  • 评测
  • 测评结果:TL
  • 用时:110ms
  • 内存:10704kb
  • [2024-11-11 02:24:12]
  • 提交

answer

def count_zeros_in_base(n, base):
    base_representation = []
    while n > 0:
        base_representation.append(n % base)
        n //= base
    return base_representation.count(0)

def find_bases_with_max_zeros(n):
    max_zeros = 0
    bases_with_max_zeros = []
    
    for base in range(2, n + 1):
        zeros_count = count_zeros_in_base(n, base)
        
        if zeros_count > max_zeros:
            max_zeros = zeros_count
            bases_with_max_zeros = [base]
        elif zeros_count == max_zeros:
            bases_with_max_zeros.append(base)
    
    return max_zeros, bases_with_max_zeros

results = []

for _ in range(int(input())):
    n = int(input())
    max_zeros, bases = find_bases_with_max_zeros(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)))

詳細信息

Test #1:

score: 100
Accepted
time: 11ms
memory: 10528kb

input:

3
11
1007
239

output:

1 3
2 3 11
2 2
3 10
1 4
2 6 15 239

result:

ok 15 numbers

Test #2:

score: 0
Accepted
time: 7ms
memory: 10628kb

input:

1
2

output:

1 1
2

result:

ok 3 number(s): "1 1 2"

Test #3:

score: 0
Accepted
time: 3ms
memory: 10704kb

input:

10
56
20
6
84
25
20
60
73
70
50

output:

3 1
2
3 1
2
1 3
2 3 6
4 1
2
2 2
2 5
3 1
2
2 2
2 3
4 1
2
4 1
2
3 1
2

result:

ok 34 numbers

Test #4:

score: 0
Accepted
time: 110ms
memory: 10664kb

input:

100
6211
4783
6225
5664
9709
5455
5424
7394
2329
3880
8260
950
2604
1366
3080
5505
4983
9595
6563
2697
2249
675
1537
5884
6070
2905
3137
5675
8138
1626
5348
8876
6065
8454
9346
3421
8857
8941
2743
9343
6201
45
1651
8575
5327
2577
4553
7595
1185
8775
7241
616
4465
3642
1657
5791
2800
1669
9307
2640
6...

output:

8 1
2
5 1
2
8 1
2
9 1
2
5 1
2
5 1
2
8 1
2
6 1
2
7 1
2
6 1
2
11 1
2
3 1
2
7 1
2
5 1
2
9 1
2
8 1
2
4 1
2
5 1
2
7 1
3
7 1
2
7 1
2
5 1
2
8 1
2
4 1
2
4 1
2
5 1
2
8 1
2
6 1
2
4 1
2
5 1
2
7 1
2
8 1
2
5 1
2
10 1
2
10 1
2
4 1
2
8 1
2
6 1
2
4 1
2
5 1
2
7 1
2
2 2
2 3
4 1
2
5 1
2
5 1
2
8 1
2
7 1
2
4 1
2
7 1
2
8...

result:

ok 309 numbers

Test #5:

score: -100
Time Limit Exceeded

input:

1000
461349
350342
809551
211152
572968
896101
718511
44614
72871
106360
141199
858436
576392
414585
897161
917037
679916
987675
507878
851589
62793
717573
119037
587678
774831
977964
313698
208868
953676
26986
273250
625834
573172
865274
105345
290197
807126
566514
193786
645978
670847
961765
72414...

output:


result: