编程1 public static boolean isCan(int[] a, int n) {         int len = a.length;         int c = a[0] == 0 ? 1 : 0;         int count = 0;         for (int i = 1; i < a.length; i++) {             if (a[i] == 1) {                 if (c > 2) {                     count += (c - 1) / 2;                     c = 0;                 }             } else {                 c++;             }             if (count >= n) {                 return true;             }         }         return false;     } 编程2     public static int perfectBag(int n, int a[]) {         int[] f = new int[n + 1];         f[0] = 1;         for (int i = 0; i < a.length; i++) {             for (int j = a[i]; j <= n; j++) {                 f[j] += f[j - a[i]];             }         }         return f[n];     }
点赞 评论

相关推荐

04-18 15:58
已编辑
门头沟学院 设计
kaoyu:这一看就不是计算机的,怎么还有个排斥洗碗?
点赞 评论 收藏
分享
点赞 评论 收藏
分享
牛客网
牛客企业服务