Accepted
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