小马智行2019软开笔试
只有第三题写全了
import java.util.*; public class Main { public static void main(String[] args) { Scanner scan = new Scanner(System.in); while(scan.hasNext()) { List<String> list = new ArrayList<>(); int n = scan.nextInt(); for(int i = 0; i < n; i++) { int l0 = scan.nextInt(); int v0 = scan.nextInt(); int l1 = scan.nextInt(); int v1 = scan.nextInt(); int x0 = scan.nextInt(); int y0 = scan.nextInt(); int r = scan.nextInt(); int x1 = scan.nextInt(); int y1 = scan.nextInt(); boolean flag = helper(l0, v0, l1, v1, x0, y0, r, x1, y1); if(flag) { list.add("YES"); } else { list.add("NO"); } } for(int i = 0; i < list.size(); i++) { System.out.println(list.get(i)); } } } private static boolean isCrush(double t0s, double t0e, double t1s, double t1e) { //System.out.println(t0s + ", " + t0e + ", " + t1s + ", " + + t1e); if(t0s > t1e) return false; if(t0e < t1s) return false; return true; } public static boolean helper(int l0, int v0, int l1, int v1, int x0, int y0, int r, int x1, int y1) { if(x0 == x1 && x1 == y1) { return true; } else { if(x1 >= x0) { return false; } else if (x1 < x0 - r) { double yuan = Math.PI * (double)r / 2; double path0 = yuan + x0 - r - x1; double t0S = path0 / (double) v0; double t0E = (path0 + l0) / (double) v0; double path1 = (double)(y1 - y0 - r); double t1S = path1 / (double) v1; double t1E = (path1 + l1) / (double) v1; boolean flag = isCrush(t0S, t0E, t1S, t1E); if(flag) { return true; } else { return false; } } else { double a = Math.pow(x1-x0+r, 2); double y = Math.sqrt(r*r - a) + y0; double jiao = Math.atan((double)((y-y0)/(x1-x0+r))); double huchang = jiao * r; double path0 = huchang; double t0S = path0 / (double) v0; double t0E = (path0 + l0) / (double) v0; double path1 = (double)(y1 - y0); double t1S = path1 / (double) v1; double t1E = (path0 + l1) / (double) v1; boolean flag = isCrush(t0S, t0E, t1S, t1E); if(flag) { return true; } else { return false; } } } } }
#笔试题目##小马智行##秋招#