結果

問題 No.1486 ロボット
ユーザー simansiman
提出日時 2021-04-26 13:39:37
言語 Ruby
(3.3.0)
結果
AC  
実行時間 171 ms / 2,000 ms
コード長 392 bytes
コンパイル時間 240 ms
コンパイル使用メモリ 11,192 KB
実行使用メモリ 30,820 KB
最終ジャッジ日時 2023-09-18 06:14:58
合計ジャッジ時間 3,707 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 84 ms
15,088 KB
testcase_01 AC 84 ms
15,080 KB
testcase_02 AC 83 ms
15,256 KB
testcase_03 AC 83 ms
15,008 KB
testcase_04 AC 85 ms
15,084 KB
testcase_05 AC 83 ms
15,296 KB
testcase_06 AC 169 ms
30,820 KB
testcase_07 AC 171 ms
30,736 KB
testcase_08 AC 127 ms
22,920 KB
testcase_09 AC 84 ms
15,144 KB
testcase_10 AC 89 ms
16,144 KB
testcase_11 AC 89 ms
16,352 KB
testcase_12 AC 84 ms
15,168 KB
testcase_13 AC 83 ms
15,088 KB
testcase_14 AC 121 ms
19,752 KB
testcase_15 AC 91 ms
16,340 KB
testcase_16 AC 100 ms
17,680 KB
testcase_17 AC 100 ms
16,880 KB
testcase_18 AC 94 ms
17,248 KB
testcase_19 AC 88 ms
15,872 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

A, B, C, D, E = gets.split.map(&:to_i)
T = (A + B).lcm(C + D)
a1 = ([1] * A + [0] * B) * (Rational(T, A + B).ceil + 1)
a2 = ([1] * C + [0] * D) * (Rational(T, C + D).ceil + 1)
ans = 0
cnt = 0

0.upto(T - 1) do |t|
  next if a1[t] == 0
  next if a2[t] == 0
  cnt += 1
end

ans += cnt * (E / T)
R = E % T

0.upto(R - 1) do |r|
  next if a1[r] == 0
  next if a2[r] == 0
  ans += 1
end

puts ans
0