結果

問題 No.3651 K-th Sum of Divisors
コンテスト
ユーザー Tuchmos
提出日時 2026-08-30 10:30:23
言語 PyPy3
(7.3.23 + ACL)
コンパイル:
pypy3 -mpy_compile _filename_
実行:
pypy3 _filename_
結果
WA  
実行時間 -
コード長 1,327 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 371 ms
コンパイル使用メモリ 96,108 KB
実行使用メモリ 107,136 KB
最終ジャッジ日時 2026-08-30 10:30:35
合計ジャッジ時間 9,966 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 26 WA * 29
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

###############################################################
#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)
        break
    vis.add(res)

if K<=len(od):
    print(od[K-1])
    exit()

K-=loop
leng=len(od)-loop
K%=leng
print(od[loop+K])
0