結果
| 問題 |
No.2829 GCD Divination
|
| コンテスト | |
| ユーザー |
titia
|
| 提出日時 | 2024-08-04 04:50:27 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 762 bytes |
| コンパイル時間 | 397 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 17,948 KB |
| 最終ジャッジ日時 | 2024-08-04 04:50:31 |
| 合計ジャッジ時間 | 4,237 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 WA * 1 TLE * 1 -- * 29 |
ソースコード
import sys
input = sys.stdin.readline
from collections import Counter
from math import gcd
N=int(input())
LIST=[]
for i in range(1,round(N**(1/2))+2):
if N%i==0:
LIST.append(i)
LIST.append(N//i)
LIST=sorted(set(LIST))
from functools import lru_cache
@lru_cache(maxsize=None)
def calc(x):
if x==1:
return 0
KO=Counter()
for i in LIST[::-1]:
if i>x:
continue
k=x//i
KO[i]+=k
for j in LIST:
if i%j==0 and j<i:
KO[j]-=KO[i]
score=0
#print(x,KO)
for i in LIST:
if x==i:
break
score+=(calc(i))*KO[i]/(x-1)
#print(i,score)
#print("!",score)
return score+x/(x-1)
print(calc(N))
titia