結果

問題 No.1236 長針と短針
ユーザー simansiman
提出日時 2021-08-18 04:29:58
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 438 bytes
コンパイル時間 301 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,544 KB
最終ジャッジ日時 2024-04-19 12:11:02
合計ジャッジ時間 3,566 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
12,160 KB
testcase_01 AC 96 ms
12,160 KB
testcase_02 AC 94 ms
12,288 KB
testcase_03 AC 92 ms
12,288 KB
testcase_04 AC 94 ms
12,160 KB
testcase_05 AC 99 ms
12,160 KB
testcase_06 WA -
testcase_07 AC 98 ms
12,160 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 91 ms
12,032 KB
testcase_12 WA -
testcase_13 AC 95 ms
12,160 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 96 ms
12,288 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

A, B = gets.split.map(&:to_i)
T = 60 * 60 * 24

def f(t)
  t * Rational(360, 60 * 60)
end

def g(t)
  t * Rational(360, 60 * 60 * 12)
end

def t1(m, s)
  (m * 60 + s) % 3600
end

def t2(h, m, s)
  ((h * 60 * 60) + m * 60 + s) % (60 * 60 * 12)
end

min_diff = Float::INFINITY
ans = 0

0.upto(3600) do |i|
  a = t1(B, i)
  b = t2(A, B, i)
  diff = (f(a) - g(b)).abs

  if min_diff > diff
    ans = i
    min_diff = diff
  end
end

puts ans
0