結果
| 問題 | No.3651 K-th Sum of Divisors |
| コンテスト | |
| ユーザー |
Tuchmos
|
| 提出日時 | 2026-08-30 10:35:39 |
| 言語 | PyPy3 (7.3.23 + ACL) |
| 結果 |
AC
不安定
|
| 実行時間 | 133 ms / 2,000 ms |
| + 621µs | |
| コード長 | 1,346 bytes |
| 記録 | |
| コンパイル時間 | 238 ms |
| コンパイル使用メモリ | 95,856 KB |
| 実行使用メモリ | 106,752 KB |
| 最終ジャッジ日時 | 2026-08-30 10:35:51 |
| 合計ジャッジ時間 | 9,464 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 55 |
ソースコード
###############################################################
#https://atcoder.jp/contests/abc249/submissions/71937223
import math
def smallest_prime_facror(n):
res=list(range(n+1))
for i in range(2,int(math.isqrt(n))+1):
if res[i]==i:
for j in range(i*i,n+1,i):
if res[j]==j:
res[j]=i
return res
spf=smallest_prime_facror(3000000)
def prime_factorization(n):
factors={}
current=n
while current>1:
factors[spf[current]]=factors.get(spf[current],0)+1
current//=spf[current]
return factors
def divisors(n):
factors=prime_factorization(n)
divs=[1]
for p,e in factors.items():
m=len(divs)
mul=1
for _ in range(e):
mul*=p
for i in range(m):
divs.append(divs[i]*mul)
return divs
###############################################################
N,K=map(int,input().split())
od=[N]
vis=set()
vis.add(N)
mod=100003
while True:
n=od[-1]
F=prime_factorization(n)
res=1
for p,e in F.items():
res*=(p**(e+1)-1)//(p-1)
res%=mod
od.append(res)
if res in vis:
loop=od.index(res)
od.pop()
break
vis.add(res)
if K<=len(od):
print(od[K-1])
exit()
K-=loop+1
leng=len(od)-loop
K%=leng
print(od[loop+K])
Tuchmos