Submission #2744991


Source Code Expand

Copy
lines = $stdin.read
array = lines.split("\n")

A,B,C = array[0].split(" ").map(&:to_i)

def f(t, a, b, c)
  ans = a*t + b * Math.sin(c*t*Math::PI)
  #puts ans
  ans
end

def ceil_index(l, r, key, a, b, c)
  #puts "left:#{l},right:#{r},key=#{key}"
  while r-l > 0.00000000001
    #m = l + ((r-l).to_f/2).to_f
    m = l + (r-l)/2
    t = f(m,a,b,c)

    if t == key
      puts t
      exit(0)
    elsif key < t
      r = m
    else
      l = m
    end
  end
  r
end

t = 0
while true
  t += 1
  ans = f(t,A,B,C)
  if ans==100
    puts t
    exit(0)
  elsif ans>100
    break
  end
end

t = ceil_index((t-1).to_f, t.to_f, 100, A, B, C)

#puts "---"
#puts f(t,A,B,C)
#puts f(1.63372043395339,A,B,C)

puts t

Submission Info

Submission Time
Task D - 高橋君ボール1号
User hiroyuking
Language Ruby (2.3.3)
Score 100
Code Size 750 Byte
Status
Exec Time 7 ms
Memory 1788 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 example_0.txt, example_1.txt
All 100 / 100 example_0.txt, example_1.txt, random_0.txt, random_1.txt, random_2.txt, random_3.txt, random_4.txt, random_5.txt, random_6.txt, random_7.txt, random_8.txt, random_9.txt, special_0.txt, special_1.txt, special_2.txt, example_0.txt, example_1.txt
Case Name Status Exec Time Memory
example_0.txt 7 ms 1788 KB
example_1.txt 7 ms 1788 KB
random_0.txt 7 ms 1788 KB
random_1.txt 7 ms 1788 KB
random_2.txt 7 ms 1788 KB
random_3.txt 7 ms 1788 KB
random_4.txt 7 ms 1788 KB
random_5.txt 7 ms 1788 KB
random_6.txt 7 ms 1788 KB
random_7.txt 7 ms 1788 KB
random_8.txt 7 ms 1788 KB
random_9.txt 7 ms 1788 KB
special_0.txt 7 ms 1788 KB
special_1.txt 7 ms 1788 KB
special_2.txt 7 ms 1788 KB