个人的吃雪糕求解 package com.wxf.exam.write; import java.util.ArrayList; import java.util.List; import java.util.Scanner; import java.util.concurrent.SynchronousQueue; public class SolveSecondQuestion {     public static void main(String[] args) {         Scanner sc = new Scanner(System.in);         int n = sc.nextInt();         List<Obj> list = new ArrayList<>();         Obj o = null;         for (int i = 0; i < n; i++) {             o = new Obj();             o.highDay = sc.nextInt();             o.one = sc.nextInt();             o.two = sc.nextInt();             o.three = sc.nextInt();             list.add(o);         }         // for (Obj oo : list)         // System.out.println(oo);         for (Obj oo : list)             isSafeDurHighDay(oo);     }     /**      * 是否安全度过高温天气      *       * @param oo      */     private static void isSafeDurHighDay(Obj oo) {         // TODO Auto-generated method stub         int one = oo.one;         int two = oo.two;         int three = oo.three;         int highDay = oo.highDay;         int count = 6;         int i;         int flag = 0; //        System.out.println(oo);         if (highDay * 6 <= one + two * 2 + three * 3) {             // 在大的前提下,再去判断             for (i = 1; i <= highDay; i++) {                 count = 6;                 while (count > 0 && (three > 0 || two > 0 || one > 0)) {                     flag = 0;                     while (count - 3 >= 0 && three > 0) {                         count -= 3;                         three--;                         flag++;                     }                     while (count - 2 >= 0 && two > 0) {                         count -= 2;                         two--;                         flag++;                     }                     while (count - 1 >= 0 && one > 0) {                         count -= 1;                         one--;                         flag++;                     }                     if (flag == 0) {                         break;                     }                 }                 if (count > 0) {                     System.out.println("No");                     break;                 }             }             if (i > highDay)                 System.out.println("Yes");         } else {             System.out.println("No");         }     } } /**  * @author Administrator  *  */ class Obj {     public int highDay;     public int one;     public int two;     public int three;     @Override     public String toString() {         return "(" + highDay + "," + one + ", " + two + ", " + three + ")";     } } //4  //1 1 1 1  //2 0 0 4  //3 0 2 5  //4 24 0 0
点赞 评论

相关推荐

05-19 15:21
已编辑
华南农业大学 Java
白火同学:你才沟通了200,说实话,北上广深杭这里面你连一座城市的互联网公司都没投满呢,更别说还有各种准一线二线城市了。等你沟通突破了三位数,还没结果再考虑转行的事吧。
点赞 评论 收藏
分享
这一集&nbsp;硕士输的很惨
找工作ing10:就是这样不是硕士不愿意脱下长衫,是人家觉得屈才了
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务