牛客的试卷你们做了吗,求大题第二题解题思路

刚牛客的考试你们都做了没。感觉如何啊。我三题大题就第一题做出来了😫😫😫😫#笔经##Java##题解#
全部评论
https://www.nowcoder.com/discuss/82233 去年我做的答案,但是今年怎么都只有 20% 的通过率,我第三题也做出来了,我都怀疑是不是测试用例有问题了
点赞 回复
分享
发布于 2019-02-20 20:51
额,你是不是忘了说你的报名科目?
点赞 回复
分享
发布于 2019-02-20 20:52
联易融
校招火热招聘中
官网直投
java的话,1->7优先性降低,很简单的 (1)003 (2)111 (3)301 (4)030 (5)220 (6)410 (7)600
点赞 回复
分享
发布于 2019-02-20 20:54
package xyz.liuyingdi.test; import java.util.Scanner; public class Main {          public static void main(String[] args) {                  Scanner sc = new Scanner(System.in);         while (sc.hasNextInt()) {             int testTimes = sc.nextInt();             for(int i = 0; i < testTimes; i++) {                 int n = sc.nextInt();                 int a = sc.nextInt();                 int b = sc.nextInt();                 int c = sc.nextInt();                 System.out.println(solve(n, a, b, c));             }         }     }          public static String solve(int n, int a, int b, int c) {                  boolean flag = true;         for(int i = 0; i < n; i++) {             if(c >= 2) {  // 0 0 2                 c -= 2;             }             else if(c >= 1 && b >= 1 && a >= 1) {  // 1 1 1                 c -= 1;                 b -= 1;                 a -= 1;             }             else if(c >= 1 && a >= 3) {  // 3 0 1                 c -= 1;                 a -= 3;             }             else if(b >= 3) {  // 0 3 0                 b -= 3;             }             else if(b >= 2 && a >= 2) {  // 2 2 0                 b -= 2;                 a -= 2;             }             else if(b >= 1 && a >= 4) {  // 4 1 0                 b -= 1;                 a -= 4;             }             else if(a >= 6) {  // 6 0 0                 a -= 6;             }             else {                 flag = false;                 break;             }         }                  String str = flag ? "Yes" : "No";         return str;     } }
点赞 回复
分享
发布于 2019-02-20 20:55
这题可以动态规划吗
点赞 回复
分享
发布于 2019-02-20 21:01
贪心么
点赞 回复
分享
发布于 2019-02-20 21:03
package myself; import java.util.Scanner; public class Main {     public static void main(String[] args) {         Scanner sc = new Scanner(System.in);         while (sc.hasNextInt()) {             int n = sc.nextInt();             int ans = 0, x;             int N, A, B, C;             for (int i = 0; i < n; i++) {                 N = sc.nextInt();                 A = sc.nextInt();                 B = sc.nextInt();                 C = sc.nextInt();                 N = N - B / 3 - C / 2;                 B %= 3;                 C %= 2;                 if (N <= 0) System.out.println("Yes");                 else if ((A + B * 2 + 3 * C < 6 * N) || ((A + B * 2 + 3 * C >= 6 * N) && (A == 0)))                     System.out.println("No");                 else System.out.println("Yes");             }         }     } }
点赞 回复
分享
发布于 2019-02-20 21:06

相关推荐

投递腾讯等公司10个岗位
点赞 评论 收藏
转发
点赞 收藏 评论
分享
牛客网
牛客企业服务