全部评论
我看懂了这个但是还在想怎么做,他就是想在里面去m个数,使得m个数分隔得最开最平均,最平均的时候他们的最小间隔就是所有情况中最大的
分享
第一题吃糖就是求二进制相加后1的个数,数量少的时候直接左移就可以,这里数比较大,用数组模拟就可以了
分享
联想
官网直投
哪个大佬能给讲讲题意。。我已经交卷了 就想知道他到底什么个意思
分享
第一题怎么做大佬?
分享
求大佬讲讲😂
分享
这家公司我选择拉黑 呕
分享
第一题我也没看明白。那个k是个啥玩意啊
分享
import sys
n = input()
n = int(n)
line = input()
nums = line.split()
nums = list(map(int,nums))
dic = {}
for num in nums:
if num in dic:
dic[num]+=1
else:
dic[num]=1
nums = list(dic.keys())
nums.sort()
ans = 0
while(len(nums)):
now = nums[0]#当前数字
ans += dic[now]%2
jinwei = dic[now]//2
if jinwei>0:
next_num = now+1
if next_num in dic:
dic[next_num] += dic[now]//2
nums = nums[1:]
else:
dic[next_num] = dic[now]//2
nums = [next_num] + nums[1:]
print(ans)
分享
我最后这个过了83,仍然不懂发生了什么 import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
public class beike01 {
public static void main(String[] args){
Scanner scanner = new Scanner(System.in);
int num = scanner.nextInt();
List<Integer> candy = new ArrayList<>();
for(int i=0; i<num; i++){
candy.add(scanner.nextInt());
}
candy.sort(new Comparator<Integer>() {
@Override
public int compare(Integer o1, Integer o2) {
return o1-o2;
}
});
int result = minCount(candy);
System.out.println(result);
}
public static int minCount(List<Integer> candy){
int result = 0;
if(candy.size() == 1) return 1;
while(candy.size()>1){
int temp = candy.get(0);
int count = 0;
for(int i=0; i<candy.size(); i++){
if(candy.get(i) != temp){
break;
}else{
count++;
}
}
for(int i=0; i<count; i++) candy.remove(0);
for(int i=0; i<count/2; i++) candy.add(0, temp+1);
result += count%2;
}
return result + candy.size();
}
}
分享
第一题,直接不断合并,能到0.9 第二个第三个,看不懂
分享
第一题不断合并,只能ac 0.9,不知道哪里错了,其他三题直接放弃了,题目都看不懂。。
分享
老哥是研发岗还是算法岗
分享
反正我是一道题都没a
分享
算法是真的难,太难了,我第二题我还问了管理员,管理员说***!我擦
分享
相关推荐
点赞 评论 收藏
转发
投递T3出行等公司10个岗位 > 🔥笔试编程真题宝典💯
点赞 评论 收藏
转发