バイクを操作してギャップをジャンプさせます。
失敗すると落ちて死にます。
考慮すべき点
- ギャップをジャンプさせるまでのスピード調整。速すぎるとオーバーランして死にます。遅ければギャップを飛び越えることができません。
- どのタイミングでジャンプさせるか
- int R : ギャップの前までの路面の長さ
- int G : ギャップの長さ
- int L : 着地後の路面の長さ
- int S : バイクのスピード
- int X : バイクの位置
出力
- "SPEED" 加速
- "JUMP" ジャンプ
- "SLOW" 減速
- "WAIT" そのまま待つ
回答例
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
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)
{
int S = int.Parse(Console.ReadLine()); // the motorbike's speed.
int X = int.Parse(Console.ReadLine()); // the position on the road of the motorbike.
Console.Error.WriteLine("G:"+G+" R:"+R + " L:"+L + " X:"+X + " S:"+S); //デバッグ用
//(ギャップ+1)のスピードであればちょうど乗り越えられることが試行錯誤から分かったので、(G+1)を目標速度とする
if((G+1) > S && X < (R-1)){ // 遅すぎる、かつ、ギャップの手前にいるので加速
Console.WriteLine("SPEED");
}else if(X == (R-1)){ // ジャンプ地点(これも試行錯誤で求めた)
Console.WriteLine("JUMP");
}else if(X > (R-1) || (G+1) < S){ //速すぎる、または、ギャップを通過したので減速
Console.WriteLine("SLOW");
}else{ // その他(ちょうど良いスピード、かつギャップの手前)
Console.WriteLine("WAIT");
}
}
}
}
所感
まだ変数と IF しか出てきませんね...
0 件のコメント:
コメントを投稿