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

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

相关推荐

ProMonkey2024:5个oc?厉害! 但是有一个小问题:谁问你了?😡我的意思是,谁在意?我告诉你,根本没人问你,在我们之中0人问了你,我把所有问你的人都请来 party 了,到场人数是0个人,誰问你了?WHO ASKED?谁问汝矣?誰があなたに聞きましたか?누가 물어봤어?我爬上了珠穆朗玛峰也没找到谁问你了,我刚刚潜入了世界上最大的射电望远镜也没开到那个问你的人的盒,在找到谁问你之前我连癌症的解药都发明了出来,我开了最大距离渲染也没找到谁问你了我活在这个被辐射蹂躏了多年的破碎世界的坟墓里目睹全球核战争把人类文明毁灭也没见到谁问你了(别的帖子偷来的,现学现卖😋)
点赞 评论 收藏
分享
点赞 收藏 评论
分享
牛客网
牛客企业服务