avatar-decorate
NotDeep level
获赞
917
粉丝
393
关注
81
看过 TA
37
中国戏曲学院
2016
算法工程师
IP属地:重庆
暂未填写个人简介
私信
关注
头像
2018-06-24 11:57
已编辑
中国戏曲学院 算法工程师
在线练习地址: 校招全国统一模拟笔试技术类编程题汇总:https://www.nowcoder.com/test/11086583/summary ----------------------------------- 牛牛偶像养成记 分析 题目给出了n次牛牛能够上台的起始时间和持续时间,那么,我们可以通过这两个时间求到每次表演的结束时间。要使得牛牛上台的次数越多,那么就只有让牛牛上一个节目的结束时间越早,能留出更多的时间来选择后面更多的上台机会。所以,我们只需要将牛牛所有节目的结束时间从小到大排序,每次取满足条件的结束时间最早的节目就行了。 时...
傻子一个:我想请问一下,牛牛与世界杯的测试用例是不是有问题,下面这组测试用例,有一个套餐为 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 点赞 评论 收藏
分享
头像
2017-08-12 18:26
已编辑
中国戏曲学院 算法工程师
练习链接: https://www.nowcoder.com/test/6291726/summary 等差数列 分析 对序列排序,然后比对一下是否等差即可。 参考code #include <bits/stdc++.h> using namespace std; int n; int x[55]; string solve() { sort(x, x + n); if(n <= 2) return "Possible"; else { int d = x[1] - x[0]; bool o...
向宇同桌: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 点赞 评论 收藏
分享
头像
2017-05-20 10:37
已编辑
中国戏曲学院 算法工程师
题目https://www.nowcoder.com/test/5217106/summary&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;变换次数&nbsp;分析&nbsp;暴力计算即可.&nbsp;参考code&nbsp;#include&nbsp;&lt;bits/stdc++.h&gt;&nbsp;using&nbsp;namespace&nbsp;std;&nbsp;int&nbsp;n,&nbsp;ans,&nbsp;tmp;&nbsp;int&nbsp;main()&nbsp;{&nbsp;cin&nbsp;&gt;&gt;&nbsp;n;&nbsp;while(n&nbsp;&gt;&nbsp;9)&nbsp;{&nbsp;tmp&nbsp;=&nbsp;1;&nbsp;for(;&nbsp;n;&nbsp;n&nbsp;/=&nbsp;10)&nbsp;tmp&nbsp;*=&nbsp;n&nbsp;%&nbsp;10...
Snail的小家:大数据三个题目的java代码,数组变换,排序子序列,牛牛的数列三题。 其中排序子序列提供了我的动态规划解法。 https://github.com/XingxingHuang/Code_Practice/tree/master/nowcoder/nowcode_0519_test 另外上面 “数组变换” 一题中参考答案似乎没考虑数组中有值为0的情况,这种情况下会产生死循环
0 点赞 评论 收藏
分享

创作者周榜

更多
关注他的用户也关注了:
牛客网
牛客企业服务