結果

問題 No.313 π
ユーザー Leonardone
提出日時 2015-12-06 05:51:05
言語 Ruby
(3.4.1)
結果
RE  
実行時間 -
コード長 542 bytes
コンパイル時間 336 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 34,560 KB
最終ジャッジ日時 2024-09-14 15:08:51
合計ジャッジ時間 159,356 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 2
other RE * 32
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

#! ruby
# yukicoder My Practice
# author: Leonardone @ NEETSDKASU

require "bigdecimal"

a = Rational(3, 1)
b = Rational(4, 1)
f = true

n = 30000

x = 2
n.times do
    y = x * (x + 1) * (x + 2)
    x += 2
    c = b / y
    if f
        a += c
        f = false
    else
        a -= c
        f = true
    end
end

_,v,* =BigDecimal::new(a, 200002).split
s = gets.chomp

if s[0] != '3'
    puts "%s 3" % [s[0]]
    exit
end


1.upto(200000) do |i|
    if v[i] != s[i + 1]
        puts "%s %s" % [s[i + 1], v[i]]
        exit
    end
end




0