結果

問題 No.53 悪の漸化式
ユーザー snuke
提出日時 2014-10-30 23:50:26
言語 Python2
(2.7.18)
結果
AC  
実行時間 13 ms / 5,000 ms
コード長 302 bytes
コンパイル時間 142 ms
コンパイル使用メモリ 6,912 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2024-12-30 14:46:30
合計ジャッジ時間 1,184 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

def gcd(x,y):
  if y == 0: return x
  return gcd(y,x%y) 

n = input()
c = [4,3]
p = [1,1]
for i in xrange(n-1):
  c.append(19*c[i+1]*p[i] - 12*c[i]*p[i+1])
  p.append(4*p[i+1]*p[i])
  g = gcd(c[i+2],p[i+2])
  c[i+2] /= g
  p[i+2] /= g
  #print c[i], p[i]
print "%.10f" % (1.0*c[n]/p[n])
0