华为笔试,能过吗?

华为三题笔试,12题写出来了,第三题没写出来,能过吗?

顺便吐槽一下:
第二题小蜜蜂采蜜,题目要求最终结果转int 我把每一段转int了,导致通过率一直为0,想了好久才发现这个错误。难受香菇,怪我没读清楚题目咯,为啥最终结果不用double呢🙃🙃🙃🙃

----------

看题要仔细呀!!!!!!#华为#
全部评论
怎么查自己多少分啊。。。。,我提前交卷了没看到分数
点赞 回复 分享
发布于 2019-03-28 17:05
我朋友的写法,AC了,留在ide里,就是排列组合吧。 public class lovely {     static double[][] arr=new double[6][2];     static double [] []dis=new double[6][6];     public static void main(String[] args) {         double distance=0;                 Scanner sc = new Scanner(System.in);             for(int i=1;i<=5;i++) {             for(int j=0;j<2;j++)arr[i][j]=sc.nextInt();                      }         for(int i=0;i<6;i++) {             for(int j=0;j<6;j++) {                 dis[i][j]=Math.sqrt(Math.abs(arr[i][0]-arr[j][0])*Math.abs(arr[i][0]-arr[j][0])+Math.abs(arr[i][1]-arr[j][1])*Math.abs(arr[i][1]-arr[j][1]));             }         }         ArrayList<Integer> save=new <Integer>ArrayList();                 save.add(1);         save.add(2);         save.add(3);         save.add(4);         save.add(5);         distance=showin(0,save);                  System.out.println((int)distance);     }          public static double showin(Integer b,ArrayList<Integer> save) {         Iterator<Integer> it = save.iterator();         double max=80000000;         if(!it.hasNext())return 0;         if(save.size()==1) {                         Integer i=it.next();             return dis[0][i]+dis[b][i];                     }         while (it.hasNext()) {             Integer a=it.next();                          ArrayList<Integer> newsave=new <Integer>ArrayList();             newsave.addAll(save);               newsave.remove(a);             Double c=showin(a, newsave);             if(max>dis[b][a]+c)max=dis[b][a]+c;                                   }         return max;     }      }
点赞 回复 分享
发布于 2019-03-27 21:52
就排列组合
点赞 回复 分享
发布于 2019-03-27 21:22
a一题能过吗。。。
点赞 回复 分享
发布于 2019-08-21 21:21
当然可以……我们这么简单,我两道也过了
点赞 回复 分享
发布于 2019-03-27 22:03
不知道叫动态规划还是回溯法,然后加了个剪枝,给算出来了,很庆幸当时脑子里突然有这个想法。
点赞 回复 分享
发布于 2019-03-27 21:54
第二题我是一只求最短距离,中间的距离是double,最后结果转的int,通过率0。楼主思路怎么写的?
点赞 回复 分享
发布于 2019-03-27 21:29
大佬求第一题思路,一直是40%卡住😂
点赞 回复 分享
发布于 2019-03-27 21:25
第三题贪心能过70%不超时,想不到简单的方法,总感觉还是回溯+优化
点赞 回复 分享
发布于 2019-03-27 21:23
和我一模一样 纠结了半个多小时
点赞 回复 分享
发布于 2019-03-27 21:23
**,我觉得第二题我犯了和你一样的错误,不然应该是对的😭
点赞 回复 分享
发布于 2019-03-27 21:17
第二题怎么做?我一直是55.56%的通过率
点赞 回复 分享
发布于 2019-03-27 21:12
请问第二题暴力?
点赞 回复 分享
发布于 2019-03-27 21:12

相关推荐

评论
点赞
8
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务