荣耀11.2通用软开笔试第二道

调了一个半小时,本地能过一交就0%,求个大佬代码😷#2021届秋招进度交流##荣耀手机#
全部评论
public static void main(String[] args) {         Scanner sc = new Scanner(System.in);         int t = sc.nextInt();         for (int i = 0; i < t; i++) {             int C = sc.nextInt();             int n = sc.nextInt();             int m = sc.nextInt();             if (C == 1) {                 System.out.println(1);                 continue;             } //            cur当前可容纳人数             int cur = 2;             int people = 2;             int count = 1;             boolean flag = true;             n+=1;             if(3*m+2*n < C){                 flag = false;
点赞 回复 分享
发布于 2021-11-02 20:11
else{                 while (cur < C) { //                人手                     int temp = 2 * cur;                     if (m > 0) {                         if (m - temp >= 0) {                             cur = (temp * 3);                             temp = 0;                         } else {                             cur = (m * 3);                             temp = temp - m;                         }                     }else{                         cur = 0;                     }                     if(temp > 0){                         if (n - temp >= 0) {                             cur += temp * 2;                         } else {                             cur += n * 2;                         }                     }                     count += 2;                 }             }             if (flag) {                 System.out.println(count);             } else {                 System.out.println(0);             }         }     }
点赞 回复 分享
发布于 2021-11-02 20:12
雨伞那道题,自己的代码贴在一二楼了😣
点赞 回复 分享
发布于 2021-11-02 20:13

相关推荐

评论
点赞
收藏
分享
牛客网
牛客企业服务