結果

問題 No.2829 GCD Divination
ユーザー ねしん
提出日時 2024-07-16 09:14:29
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 445 bytes
コンパイル時間 206 ms
コンパイル使用メモリ 82,272 KB
実行使用メモリ 88,848 KB
最終ジャッジ日時 2024-07-16 09:14:40
合計ジャッジ時間 5,676 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3 WA * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

from fractions import Fraction
from collections import defaultdict
from decimal import Decimal
def gcd(a,b):
  if b==0:
    return a
  else:
    return gcd(b,a%b)
def VAL_C(N):
  dp=[Fraction(0,1)]*(N+1)
  for i in range(2,N+1):
    d=0
    for m in range(1,i):
      d=(d+dp[gcd(i,m)]*Fraction(1,i))
    d=(d+1)*Fraction(i,i-1)
    dp[i]=d
  return dp[N]
N=int(input())
if N>4000:
	print(0)
else:
	print(VAL_C(N).numerator/VAL_C(N).denominator)
0