結果

問題 No.8 N言っちゃダメゲーム
ユーザー nishimanishima
提出日時 2015-11-07 23:47:52
言語 Ruby
(3.3.0)
結果
AC  
実行時間 82 ms / 5,000 ms
コード長 497 bytes
コンパイル時間 153 ms
コンパイル使用メモリ 11,224 KB
実行使用メモリ 15,300 KB
最終ジャッジ日時 2023-10-11 15:16:19
合計ジャッジ時間 1,766 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,032 KB
testcase_01 AC 80 ms
15,072 KB
testcase_02 AC 80 ms
15,136 KB
testcase_03 AC 79 ms
15,076 KB
testcase_04 AC 79 ms
15,292 KB
testcase_05 AC 79 ms
15,300 KB
testcase_06 AC 80 ms
15,064 KB
testcase_07 AC 80 ms
15,288 KB
testcase_08 AC 82 ms
15,072 KB
testcase_09 AC 81 ms
15,244 KB
testcase_10 AC 78 ms
15,144 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def game( n, k )

=begin
	n1 = n % ( k + 1 )	

	# n1   をいったら負け
	n1 = 0 ... 先手勝ち
	n1 = 1 ... 先手負け

	n1 >= 2 
	# n1 - 1  を言えたら勝ち

	(n1-1) <= k ? "win" : "lose"
=end

	n1 = n % ( k + 1 )
	if n1 == 0
		"Win"
	elsif n1 == 1
		"Lose"
	else
		(n1-1) <= k ? "Win" : "Lose"
	end
end

p = $stdin.gets.chomp.to_i
ans = []
1.upto( p ){
	question = $stdin.gets.chomp.split(/ /).map(&:to_i)
	ans << game( question[ 0 ], question[ 1 ] )
}
ans.each{ |a|
	puts a
}
0