/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 35ms 18.27 MiB
#2 Accepted 114ms 11.875 MiB
#3 Accepted 120ms 11.879 MiB
#4 Accepted 129ms 11.875 MiB
#5 Accepted 119ms 11.875 MiB
#6 Accepted 129ms 11.871 MiB
#7 Accepted 167ms 12.203 MiB
#8 Accepted 288ms 13.066 MiB
#9 Accepted 372ms 17.379 MiB
#10 Accepted 815ms 17.469 MiB
#11 Accepted 1375ms 17.527 MiB
#12 Accepted 1291ms 17.484 MiB
#13 Accepted 1454ms 17.453 MiB
#14 Accepted 1264ms 17.453 MiB
#15 Accepted 1263ms 17.484 MiB
#16 Accepted 1524ms 17.461 MiB
#17 Accepted 1487ms 28.148 MiB
#18 Accepted 3263ms 26.375 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:45:56
Judged At
2024-11-11 03:40:31
Judged By
Score
100
Total Time
3263ms
Peak Memory
28.148 MiB