updated on 2019-02-04
<?php $first_line=explode(" ",fgets(STDIN)); $first_line=filter_var_array($first_line,FILTER_SANITIZE_NUMBER_INT); $o_y=$first_line[0]; $s=$first_line[1]; $θ=$first_line[2]; $θ=deg2rad($θ); // 角度をrad変換 $second_line=explode(" ",fgets(STDIN)); $second_line=filter_var_array($second_line,FILTER_SANITIZE_NUMBER_INT); $x=$second_line[0]; $y=$second_line[1]; $a=$second_line[2]; // 矢の軌道 $f1 = $o_y+$x*tan($θ); $f2 = (9.8*pow($x, 2))/(2*pow($s, 2)*pow(cos($θ), 2)); $x_y = $f1 - $f2; if ($y-$a/2+0.05<=$x_y && $y+$a/2-0.05>=$x_y) { echo "Hit ".abs(round($x_y-$y, 1))."\n"; }else{ echo "Miss\n"; } ?>