网易java开发笔试,第二题可以求思路么?

有没有参加今天网易java开发笔试的童鞋,第二题可以求思路么,明明感觉很简单,写出来ac是0?😂😂😂#网易##笔试题目##Java工程师#
全部评论
我太难受了,今天下午体测到四点半,去了半条命,测完跑回实验室就开始做,难受
点赞 回复 分享
发布于 2019-09-21 17:15
public class Main {     public static void main(String[] args) {         Scanner input = new Scanner(System.in);         int n = input.nextInt();         int[] arr = new int[4];         for(int i=0; i<n;i++){             for(int j=0; j<4; j++){                 arr[j] = input.nextInt();             }             cal(arr);         }     }     public static void cal(int[] arr){         int A = arr[0];         int B = arr[1];         int p = arr[2];         int q = arr[3];         if(B <= A){             System.out.println(0);         }else {             int count = 0;             while(B > A+p){                 if( (A + p) > (A + p * q)){                     A = A + p;                 }else{                     p = p * q;                 }                 count++;             }             System.out.println(++count);         }     } } 第二题ac代码
点赞 回复 分享
发布于 2019-09-21 17:14
public static void main(String[] args) { Scanner sc = new Scanner(System.in); int t = sc.nextInt(); while (t > 0) { int a = sc.nextInt(); int b = sc.nextInt(); int p = sc.nextInt(); int q = sc.nextInt(); int total = 0; while (a < b) { if (a + p >= b) { a = a + p; } else { p *= q; } total++; } System.out.println(total); } sc.close(); }
点赞 回复 分享
发布于 2019-09-21 17:08

相关推荐

07-17 11:50
门头沟学院 Java
投递腾讯等公司7个岗位
点赞 评论 收藏
分享
06-17 00:26
门头沟学院 Java
程序员小白条:建议换下项目,智能 AI 旅游推荐平台:https://github.com/luoye6/vue3_tourism_frontend 智能 AI 校园二手交易平台:https://github.com/luoye6/vue3_trade_frontend GPT 智能图书馆:https://github.com/luoye6/Vue_BookManageSystem 选项目要选自己能掌握的,然后最好能自己拓展的,分布式这种尽量别去写,不然你只能背八股文了,另外实习的话要多投,尤其是学历不利的情况下,多找几段实习,最好公司title大一点的
无实习如何秋招上岸
点赞 评论 收藏
分享
评论
1
1
分享

创作者周榜

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