网易笔试记录

网易2023届秋季校园招聘笔试0820-通用技术

编程题1

image-20220820152143697

image-20220820152157447

编程题2

image-20220820152429298

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int[] nums = new int[n];
int oddMax = -1, singMax = -1;
for (int i = 0; i < n; i++) {
nums[i] = scanner.nextInt();
if (i % 2 == 0)
oddMax = Math.max(oddMax, nums[i]);
else
singMax = Math.max(singMax, nums[i]);
}
if (oddMax == singMax)
singMax += 1;
BigInteger ans = new BigInteger("0");
for (int i = 0; i < n; i++) {
int temp = i % 2 == 0 ? oddMax - nums[i] : singMax - nums[i];
ans = ans.add(new BigInteger(String.valueOf(temp)));
}
System.out.println(ans);
}
}

image-20220820160603979

编程题3

image-20220820152603406

image-20220820152616346

编程题4

image-20220820152631279

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int n = scanner.nextInt();
int[] nums = new int[n];
for (int i = 0; i < n; i++)
nums[i] = scanner.nextInt();

int ans = 0;
for (int i = 0; i < n; i++) {
for (int k = i+2; k < n; k++) {
for (int j = i+1; j < k; j++)
if (nums[i] == nums[k] && nums[i] > nums[j])
ans++;
}
}
System.out.println(ans);
}
}

image-20220820153621396


网易2023届秋季校园招聘笔试0820-通用技术
http://example.com/2022/08/20/笔试记录/网易2023届秋季校园招聘笔试0820-通用技术/
作者
madao33
发布于
August 20, 2022
许可协议