小马智行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;  }  }  }  }
}

#笔试题目##小马智行##秋招#
全部评论

相关推荐

10-09 00:50
已编辑
长江大学 算法工程师
不期而遇的夏天:1.同学你面试评价不错,概率很大,请耐心等待;2.你的排名比较靠前,不要担心,耐心等待;3.问题不大,正在审批,不要着急签其他公司,等等我们!4.预计9月中下旬,安心过节;5.下周会有结果,请耐心等待下;6.可能国庆节前后,一有结果我马上通知你;7.预计10月中旬,再坚持一下;8.正在走流程,就这两天了;9.同学,结果我也不知道,你如果查到了也告诉我一声;10.同学你出线不明朗,建议签其他公司保底!11.同学你找了哪些公司,我也在找工作。
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务