/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 40ms 18.312 MiB
#2 Accepted 186ms 11.875 MiB
#3 Accepted 197ms 11.879 MiB
#4 Accepted 211ms 11.879 MiB
#5 Accepted 199ms 11.879 MiB
#6 Accepted 209ms 11.879 MiB
#7 Accepted 246ms 12.215 MiB
#8 Accepted 420ms 13.074 MiB
#9 Accepted 706ms 16.426 MiB
#10 Accepted 1551ms 17.543 MiB
#11 Accepted 2527ms 17.531 MiB
#12 Accepted 1792ms 17.484 MiB
#13 Accepted 1335ms 17.457 MiB
#14 Accepted 1358ms 17.461 MiB
#15 Accepted 1531ms 17.453 MiB
#16 Accepted 1875ms 17.453 MiB
#17 Accepted 1644ms 28.168 MiB
#18 Accepted 3516ms 26.395 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:40:59
Judged At
2024-11-11 03:40:32
Judged By
Score
100
Total Time
3516ms
Peak Memory
28.168 MiB