ピョンピョンするバイクを孤島に追いやるゲーム。
行くのはいいけど、どうやって帰るんだろう……。
using System; using System.Linq; using System.IO; using System.Text; using System.Collections; using System.Collections.Generic; /** * Auto-generated code below aims at helping you parse * the standard input according to the problem statement. **/ class Player { static void Main(string[] args) { int R = int.Parse(Console.ReadLine()); // the length of the road before the gap. int G = int.Parse(Console.ReadLine()); // the length of the gap. int L = int.Parse(Console.ReadLine()); // the length of the landing platform. // game loop while (true) { string pMode = "WAIT"; //プレイヤーは基本WAIT int S = int.Parse(Console.ReadLine()); // the motorbike's speed. int X = int.Parse(Console.ReadLine()); // the position on the road of the motorbike. // Write an action using Console.WriteLine() // To debug: Console.Error.WriteLine("Debug messages..."); Console.Error.WriteLine("R:"+R); //穴までの距離 Console.Error.WriteLine("G:"+G); //穴の大きさ Console.Error.WriteLine("L:"+L); //穴の後にある道の長さ Console.Error.WriteLine("X:"+X); //現在位置 if(S < G+1) pMode = "SPEED"; //スピードが穴の大きさより小さかったら加速 else if(S > G+1) pMode = "SLOW"; //スピードが穴の大きさより大きかったら減速 if(X == R-1) pMode = "JUMP"; //穴の手前でジャンプ if(X > R+G-1) pMode = "SLOW"; //穴の距離以後は減速 Console.WriteLine(pMode); // A single line containing one of 4 keywords: SPEED, SLOW, JUMP, WAIT. } } }
なんかもっといい方法ありそうなんだけど私の頭ではちょっと…。
- 作者: 中村うさぎ
- 出版社/メーカー: 文藝春秋
- 発売日: 2012/09/20
- メディア: Kindle版
- この商品を含むブログを見る