解题思路:
注意事项:
参考代码:
import java.util.Scanner; public class C1075 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); while (sc.hasNext()) { int L = sc.nextInt(), W = sc.nextInt(), x = sc.nextInt(), y = sc.nextInt(), r = sc.nextInt(), a = sc.nextInt(), v = sc.nextInt(), s = sc.nextInt(); if(L == 0 && W == 0 && x == 0 && y == 0 && r == 0 && a == 0 && v == 0 && s == 0){ break; } int dis = v * s; double radians = Math.toRadians(a); //球心在Y轴和X轴移动的总距离 double disY = Math.abs(Math.sin(radians) * dis), disX = Math.abs(Math.cos(radians) * dis); double rsX = r, rsY = 0; //表示球心的落点 //Y轴处理 int maxDisY = W - r; boolean flagUp = (a >= 0 && a <= 180); while(true){ if(flagUp){ //上升 if(y + disY <= maxDisY){ rsY = y + disY; break; }else{ disY = disY - (maxDisY - y); y = maxDisY; flagUp = false; } }else{ //下降 if(disY <= y){ rsY = y - disY; break; }else{ disY = disY - (y - r); y = r; flagUp = true; } } } //X轴处理 int maxDisX = L - r; flagUp = (a <= 90 || a>= 270); while(true){ if(flagUp){ //上升 if(x + disX <= maxDisX){ rsX = x + disX; break; }else{ disX = disX - (maxDisX - x); x = maxDisX; flagUp = false; } }else{ //下降 if(disX <= x){ rsX = x - disX; break; }else{ disX = disX - (x - r); x = r; flagUp = true; } } } System.out.printf("%.2f %.2f\n", rsX, rsY); } sc.close(); } }
0.0分
1 人评分