#! ruby # yukicoder My Practice # author: Leonardone @ NEETSDKASU require "bigdecimal" a = Rational(3, 1) b = Rational(4, 1) f = true n = 10000 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