/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 36ms 18.324 MiB
#2 Accepted 111ms 11.879 MiB
#3 Accepted 125ms 11.879 MiB
#4 Accepted 121ms 11.883 MiB
#5 Accepted 116ms 11.875 MiB
#6 Accepted 128ms 11.879 MiB
#7 Accepted 148ms 12.211 MiB
#8 Accepted 228ms 13.707 MiB
#9 Accepted 370ms 17.418 MiB
#10 Accepted 808ms 17.461 MiB
#11 Accepted 1240ms 17.453 MiB
#12 Accepted 1353ms 17.457 MiB
#13 Accepted 1261ms 17.477 MiB
#14 Accepted 1270ms 17.531 MiB
#15 Accepted 1344ms 17.48 MiB
#16 Accepted 1514ms 17.527 MiB
#17 Accepted 1469ms 28.102 MiB
#18 Accepted 3415ms 26.391 MiB

Code

import math as m
t = int(input())
for _ in range(t):
    n,x = map(int, input().split())
    a = list(map(int,input().split()))
    ans = [0]*1000001
    
    for ai in a:
        sq = int(m.sqrt(ai))
        for ii in range(1,sq+1,1):
            if(ai%ii):
                continue
            if(ii==ai//ii):
                ans[ii] += ai
            else:
                ans[ii] += ai
                ans[ai//ii] += ai
    
    sum = ans[x]
    sol = x
    for i in range(x,0,-1):
        if(ans[i]<=sum):
            sol=i
            sum=ans[i]
    print(sol)

Information

Submit By
Type
Submission
Problem
P1039 Prince Roy, the undisputed ruler of the world
Language
Python 3 (Python 3.12.3)
Submit At
2024-03-20 17:44:05
Judged At
2024-11-11 03:40:31
Judged By
Score
100
Total Time
3415ms
Peak Memory
28.102 MiB