求问今天的模拟考试第二道题,雪糕的那个

求问今天的模拟考试第二道题,雪糕的那个,在我的eclipse上编译成功且测试了几个例子都输出正确了,
为啥在线提交一个用例都不对,求大神们指导下,看下我的代码哪里有问题,笔试老过不了好难受
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int T = Integer.parseInt(in.nextLine());
        int[][] s = new int[T][4];
        String a = "";
        for(int i = 0; i < T; i++){
            a = in.nextLine().replace(" ", "");
            for(int j = 0; j < 4; j++){
                s[i][j] = a.charAt(j);
            }
        }
        String flag = "";
        for(int i = 0; i < T; i++){
            if(6*s[i][0] == s[i][1] + 2*s[i][2] + 3*s[i][3]){
                flag = "Yes";
            }else{
                flag = "No";
            }
            System.out.println(flag);
        }
    }
}

#笔试题目##Java工程师#
全部评论
我也是这个思路,不知道为啥不对
点赞 回复
分享
发布于 2018-05-23 21:09
你忘记了题目说的是开了一盒就要整吃的,还有不应该用等于的,等于是刚好吃完的,但是雪糕完全可能比需要吃的多的 至少也应该是一个小于等于吧
点赞 回复
分享
发布于 2018-05-23 21:12
联想
校招火热招聘中
官网直投
Math.max(a[1]/6+a[2]/3+a[3]/2, min+(a[1]-min)/6+(a[2]-min)/3+(a[3]-min)/2)>=a[0]?"Yes":"No"; 这样就过了20% 想着还有 1A+1B+1C 3A+C 2A+2B 4A+B 这几种,不过加上了还是20%
点赞 回复
分享
发布于 2018-05-23 21:15
只判断 6N>A+2B+3C 就可以90%
点赞 回复
分享
发布于 2018-05-23 21:17
给的例子手动测试过了,但是拷贝上去 报错,不通过 public class 牛牛吃雪糕 {     static String[] res = null;     public static void main(String[] args) {         Scanner sc = new Scanner(System.in);         int N = sc.nextInt();// 数据组数         res = new String[N];         int[][] data = new int[N][4];         for (int i = 0; i < N; i++) {             Scanner scc = new Scanner(System.in);             String[] input = scc.nextLine().split(" ");             for (int j = 0; j < input.length; j++) {                 data[i][j] = Integer.parseInt(input[j]);             }         }         iceCream(data);         for (int i = 0; i < res.length; i++) {             System.out.println(res[i]);         }     }     public static void iceCream(int[][] data) {         for (int i = 0; i < data.length; i++) {             int n = data[i][0];             int a = data[i][1];             int b = data[i][2];             int c = data[i][3];             process(i, n, a, b, c);         }     }     public static void process(int i, int n, int a, int b, int c) {         int aDay = a / 6;         int bDay = b / 3;         int cDay = c / 2;         int resDay = n - (aDay + bDay + cDay);// 剩余的天数         if (resDay <= 0) {             res[i] = "Yes";             return;         } else {             int resA = a % 6;             int resB = b % 3;             int resC = c % 2;             if ((resC == 1 && resA >= 3) || (resB == 1 && resA >= 4) || (resB == 2 && resA >= 2)                     || (resC == 1 && resB >= 1 && resA >= 1)) {                 res[i] = "Yes";                 return;             }         }         res[i] = "No";     } }
点赞 回复
分享
发布于 2018-05-23 21:22
感觉这道题,不知道是我没理解透? 我是这样想的 每天都吃6根雪糕,都吃不完,肯定不行就是 a+2*b+3*c>6n   false 还有就是每天只吃一盒,都不够的话,也不行  即 a+b+c<n   false 介于这两者之间的,我感觉都行啊 就不知道为什么不对
点赞 回复
分享
发布于 2018-05-26 10:06

相关推荐

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