codingame/FACILE/Mars Lander - Niveau 1/script.php
2015-03-02 19:42:39 +01:00

56 lines
1.4 KiB
PHP

<?php
/**
* Auto-generated code below aims at helping you parse
* the standard input according to the problem statement.
**/
fscanf(STDIN, "%d",
$N // the number of points used to draw the surface of Mars.
);
for ($i = 0; $i < $N; $i++)
{
fscanf(STDIN, "%d %d",
$LAND_X, // X coordinate of a surface point. (0 to 6999)
$LAND_Y // Y coordinate of a surface point. By linking all the points together in a sequential fashion, you form the surface of Mars.
);
}
// game loop
while (TRUE)
{
fscanf(STDIN, "%d %d %d %d %d %d %d",
$X,
$Y,
$HS, // the horizontal speed (in m/s), can be negative.
$VS, // the vertical speed (in m/s), can be negative.
$F, // the quantity of remaining fuel in liters.
$R, // the rotation angle in degrees (-90 to 90).
$P // the thrust power (0 to 4).
);
// Write an action using echo(). DON'T FORGET THE TRAILING \n
// To debug (equivalent to var_dump): error_log(var_export($var, true));
if ($R !== 0) {
if ($R > 0) {
echo -$R, ' 0', "\n";
} else {
echo $R, ' 0', "\n";
}
}
error_log(var_export($VS, true));
if ($Y > 2300) {
echo 0, ' 1', "\n";
}
elseif ($Y > 1900) {
echo 0, ' 2', "\n";
}
else {
if ($VS < -39) {
echo 0, ' 4', "\n";
} else {
echo '0 0', "\n";
}
}
}
?>