# 第十四届蓝桥杯三月真题刷题训练——第 10 天（3.13）

serein_2216 2023-03-13 16:47:04

``````import java.util.Scanner;
// 1:无需package
// 2: 类名必须Main, 不可修改

public class Main {
public static void main(String[] args) {
System.out.print(19 + 20 * 21 + 4);
}
}``````

``````import java.util.*;
import java.io.*;
// 1:无需package
// 2: 类名必须Main, 不可修改

public class Main {
static PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));

public static void main(String[] args) throws IOException {
long a = Long.parseLong(s[0]);
long b = Long.parseLong(s[1]);
long n = Long.parseLong(s[2]);

long weekCount = a * 5 + b * 2;

long day = n / weekCount * 7;
long remain = n % weekCount;
int needDay = 1;
while(remain > 0) {
if(needDay == 6 || needDay == 7) {
remain -= b;
} else {
remain -= a;
}
needDay++;
day++;
}
System.out.print(day);
}
}``````

``````import java.util.Scanner;
// 1:无需package
// 2: 类名必须Main, 不可修改

public class Main {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
//在此输入您的代码...
int n = scan.nextInt();
for(int i = 1; i <= n; i++) {
int max = Math.max(n - i, i - 1);
System.out.println(max * 2);
}
scan.close();
}
}``````

k倍区间(朴素版)

``````import java.util.*;
import java.io.*;
// 1:无需package
// 2: 类名必须Main, 不可修改

public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n = sc.nextInt();
int k = sc.nextInt();

long result = 0;
int[] arr = new int[n + 1];
int[] preSum = new int[n + 1];
int[] map = new int[n + 1];
for(int i = 1; i <= n; i++) {
arr[i] = sc.nextInt();
preSum[i] += (preSum[i - 1] + arr[i]) % k;
result += map[preSum[i]];
map[preSum[i]]++;
}

System.out.print(result + map[0]);
}
}``````

...全文
4 回复 打赏 收藏 举报

4.2w+

2023-03-13 16:47

刷题！