滴滴笔试0904
滴滴笔试
// 魅力值
#滴滴笔试##秋招##滴滴23秋招笔试有点儿难啊#
9/4日第一题只过了73%,第二题A了
桃子装箱
public class MainDD01 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String[] one = br.readLine().split(" ");
int n = Integer.parseInt(one[0]);
int k = Integer.parseInt(one[1]);
String[] taoZi = br.readLine().split(" ");
int[] taoZiArr = new int[n];
int allSum = 0;
for (int i = 0; i < taoZi.length; i++) {
taoZiArr[i] = Integer.parseInt(taoZi[i]);
allSum += taoZiArr[i];
}
double allAvg = allSum * 1.0 / n;
Arrays.sort(taoZiArr);
int max = taoZiArr[n - 1];
int ans = n;
for(int i = n - 1; i > 0; i--){
double tempAvg = allSum * 1.0 / (i + 1);
if(taoZiArr[i] > tempAvg * k){
allSum -= taoZiArr[i];
ans--;
continue;
}
}
System.out.println(ans);
}
} // 魅力值
public class MainDD03 {
public static void main(String[] args) throws IOException {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int n = Integer.parseInt(br.readLine());
String[] one = br.readLine().split(" ");
String[] two = br.readLine().split(" ");
String[] three = br.readLine().split(" ");
int[] L = new int[one.length];
int[] R = new int[two.length];
int[] T = new int[three.length];
for (int i = 0; i < one.length; i++) {
L[i] = Integer.parseInt(one[i]);
}
for (int i = 0; i < two.length; i++) {
R[i] = Integer.parseInt(two[i]);
}
for (int i = 0; i < three.length; i++) {
T[i] = Integer.parseInt(three[i]);
}
for(int i = 0; i < n; i++){
int ans = 0;
for(int start = L[i]; start <= R[i]; start++){
int t = getBeaute(start);
if(t == T[i]) ans++;
}
System.out.print(ans + " ");
}
}
// 计算魅力值
public static int getBeaute(int i){
int temp = i % 10;
i /= 10;
while(i > 0){
temp ^= i % 10;
i /= 10;
}
return temp;
}
} #滴滴笔试##秋招##滴滴23秋招笔试有点儿难啊#

查看17道真题和解析