結果

問題 No.53 悪の漸化式
ユーザー snukesnuke
提出日時 2014-10-30 23:50:26
言語 Python2
(2.7.18)
結果
AC  
実行時間 12 ms / 5,000 ms
コード長 302 bytes
コンパイル時間 60 ms
コンパイル使用メモリ 6,640 KB
実行使用メモリ 6,204 KB
最終ジャッジ日時 2023-08-28 23:32:00
合計ジャッジ時間 1,070 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 9 ms
5,988 KB
testcase_01 AC 12 ms
6,144 KB
testcase_02 AC 11 ms
5,972 KB
testcase_03 AC 11 ms
6,056 KB
testcase_04 AC 10 ms
5,972 KB
testcase_05 AC 9 ms
5,972 KB
testcase_06 AC 10 ms
6,060 KB
testcase_07 AC 10 ms
6,044 KB
testcase_08 AC 10 ms
6,128 KB
testcase_09 AC 9 ms
6,064 KB
testcase_10 AC 10 ms
6,068 KB
testcase_11 AC 9 ms
6,068 KB
testcase_12 AC 10 ms
6,144 KB
testcase_13 AC 10 ms
6,056 KB
testcase_14 AC 10 ms
6,092 KB
testcase_15 AC 9 ms
6,032 KB
testcase_16 AC 10 ms
6,192 KB
testcase_17 AC 10 ms
6,196 KB
testcase_18 AC 11 ms
6,204 KB
testcase_19 AC 10 ms
6,152 KB
権限があれば一括ダウンロードができます

ソースコード

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