結果

問題 No.8 N言っちゃダメゲーム
ユーザー 👑 horiesinitihoriesiniti
提出日時 2023-01-18 14:15:24
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,418 ms / 5,000 ms
コード長 263 bytes
コンパイル時間 255 ms
コンパイル使用メモリ 11,560 KB
実行使用メモリ 77,836 KB
最終ジャッジ日時 2023-09-02 09:08:19
合計ジャッジ時間 7,524 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 81 ms
15,052 KB
testcase_01 AC 80 ms
15,128 KB
testcase_02 AC 80 ms
15,244 KB
testcase_03 AC 744 ms
54,352 KB
testcase_04 AC 1,418 ms
77,836 KB
testcase_05 AC 1,220 ms
77,836 KB
testcase_06 AC 492 ms
41,980 KB
testcase_07 AC 538 ms
45,004 KB
testcase_08 AC 614 ms
50,384 KB
testcase_09 AC 635 ms
51,552 KB
testcase_10 AC 674 ms
54,480 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

def f()
	n,m=gets.split(" ").map{|e| e.to_i}
	dp=Array.new(n+1,0)
	dp[1]=1
	s1=1
	2.upto(n){|i|
		if s1>0 then
			dp[i]=0
		else
			dp[i]=1
		end
		s1+=dp[i]
		if i-m>0 then
			s1-=dp[i-m]
		end
	}
	puts (dp[n]==1)?("Lose"):("Win")
end
n=gets.to_i
n.times{
	f()
}
0