結果

問題 No.405 ローマ数字の腕時計
ユーザー rkyrky
提出日時 2017-10-28 13:06:55
言語 Ruby
(3.3.0)
結果
AC  
実行時間 86 ms / 2,000 ms
コード長 810 bytes
コンパイル時間 75 ms
コンパイル使用メモリ 11,304 KB
実行使用メモリ 15,356 KB
最終ジャッジ日時 2023-09-21 00:30:08
合計ジャッジ時間 3,518 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 85 ms
15,156 KB
testcase_01 AC 81 ms
15,148 KB
testcase_02 AC 82 ms
15,264 KB
testcase_03 AC 82 ms
15,156 KB
testcase_04 AC 83 ms
15,296 KB
testcase_05 AC 84 ms
15,344 KB
testcase_06 AC 84 ms
15,144 KB
testcase_07 AC 85 ms
15,292 KB
testcase_08 AC 83 ms
15,128 KB
testcase_09 AC 83 ms
15,180 KB
testcase_10 AC 82 ms
15,356 KB
testcase_11 AC 83 ms
15,324 KB
testcase_12 AC 86 ms
15,320 KB
testcase_13 AC 84 ms
15,068 KB
testcase_14 AC 84 ms
15,152 KB
testcase_15 AC 84 ms
15,128 KB
testcase_16 AC 82 ms
15,296 KB
testcase_17 AC 84 ms
15,108 KB
testcase_18 AC 84 ms
15,172 KB
testcase_19 AC 84 ms
15,056 KB
testcase_20 AC 83 ms
15,176 KB
testcase_21 AC 83 ms
15,168 KB
testcase_22 AC 84 ms
15,200 KB
testcase_23 AC 84 ms
15,296 KB
testcase_24 AC 82 ms
15,144 KB
testcase_25 AC 83 ms
15,060 KB
testcase_26 AC 83 ms
15,068 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

class No405
	attr_accessor :list, :time, :count, :start_time, :end_time

	def initialize
		self.time, self.count = gets.split.map(&:to_s)
		self.list = ["I", "II", "III", "IIII", "V", "VI", "VII", "VIII", "IX", "X", "XI", "XII"]
		for i in 0...self.list.size do
			self.start_time = i if self.time == self.list[i]
		end
		self.end_time = self.start_time + self.count.to_i
	end

	def twenty_four_more_end_time end_time
		while self.end_time >= 12
			self.end_time -= 12
		end
	end

	def end_time_calc
		if self.end_time >= 24
			twenty_four_more_end_time end_time
		elsif self.end_time < 0
			self.end_time *= -1
			twenty_four_more_end_time end_time
			self.end_time *= -1
		end
	end

	def run 
		end_time_calc
		puts end_time >= 12 ? list[end_time - 12] : list[end_time]
	end
end

no405 = No405.new 
no405.run
0