wbq9224:序列最小化,直接输出(n - k) / (k - 1) + 1即可ac,o(1)。会算卷积核的应该能看懂是啥意思吧。

0 点赞 评论 收藏
分享
傻子一个:我想请问一下,牛牛与世界杯的测试用例是不是有问题,下面这组测试用例,有一个套餐为 22块买69张门票,显然,44块可以买138张门票,大于等于117张门票,比对应输出472要小。对应输出给出的就不是正确答案。 您的代码已保存 答案错误:您提交的程序没有通过所有的测试用例 case通过率为80.00% 测试用例: 116 26 450 230 15 531 70 777 63 589 61 266 81 322 77 517 73 820 68 241 77 103 42 256 91 750 87 866 51 569 97 524 83 173 2 22 69 653 14 846 17 896 69 111 90 194 68 326 2 335 18 175 79 933 55 对应输出应该为: 472 你的输出为: 44
0 点赞 评论 收藏
分享
0 点赞 评论 收藏
分享

0 点赞 评论 收藏
分享
2018-04-09 21:09
中国戏曲学院 算法工程师 algorithme...:牛牛的下象棋复杂度应该是O(9*9*8*K), 不是 O(81K) 同样的算法,Python版本只能过60% 后面超时。

0 点赞 评论 收藏
分享
向宇同桌:编程题开放练习了 https://www.nowcoder.com/test/9763997/summary
0 点赞 评论 收藏
分享
江沢直树:运**做了三道最简单的题 ↑_↑

0 点赞 评论 收藏
分享
水水水水水水水水水水...:有没有python的,题解,python小白做不下去了
0 点赞 评论 收藏
分享
向宇同桌:import java.util.*;
import java.lang.*;
public class Main {
public static Integer[] chess_min(Integer[] X, Integer[] Y, Integer n) {
Set<Integer> xAxis = new HashSet<Integer>(Arrays.asList(X));
Set<Integer> yAxis = new HashSet<Integer>(Arrays.asList(Y));
List<List<Integer>> centers = new ArrayList<List<Integer>>();
for (Integer x: xAxis) {
for (Integer y: yAxis) {
List<Integer> distances = new ArrayList<Integer>();
for (Integer i=0; i<n; i++) {
distances.add(Math.abs(X[i]-x) + Math.abs(Y[i]-y));
}
Collections.sort(distances);
centers.add(distances);
}
}
Integer[] min_step = new Integer[n];
Integer[] sum = new Integer[centers.size()];
for (Integer i=0; i<centers.size(); i++) {
sum[i] = 0;
}
for (Integer i=0; i<n; i++) {
for (Integer j=0; j<centers.size(); j++) {
sum[j] += centers.get(j).get(i);
}
min_step[i] = Collections.min(Arrays.asList(sum));
}
return min_step;
}
public static void main(String[] args) {
Scanner in = new Scanner(System.in
);
while(in.hasNext()) {
Integer n = in.nextInt();
Integer[] X = new Integer[n];
Integer[] Y = new Integer[n];
for (Integer i=0; i<n; i++) {
X[i] = in.nextInt();
}
for (Integer i=0; i<n; i++) {
Y[i] = in.nextInt();
}
StringBuilder str = new StringBuilder();
for (Integer i: chess_min(X, Y, n)) {
str.append(i+" ");
}
System.out.println(str.substring(0,str.length()-1));
}
}
}
棋子 java过的
0 点赞 评论 收藏
分享
遇见更美的自己:猜数做了一个多小时,最后还是没有思路,看别人几行代码就搞定了,,,内心很受伤啊
0 点赞 评论 收藏
分享
kczno1:第一题有O(n)的做法,见https://loj.ac/problem/6191/statistics/fastest (不过我不会)

0 点赞 评论 收藏
分享

0 点赞 评论 收藏
分享
Holiday_12...:dp 不到三维都不算题了吗。。
0 点赞 评论 收藏
分享
Snail的小家:大数据三个题目的java代码,数组变换,排序子序列,牛牛的数列三题。 其中排序子序列提供了我的动态规划解法。
https://github.com/XingxingHuang/Code_Practice/tree/master/nowcoder/nowcode_0519_test
另外上面 “数组变换” 一题中参考答案似乎没考虑数组中有值为0的情况,这种情况下会产生死循环
0 点赞 评论 收藏
分享
创作者周榜
更多
关注他的用户也关注了: