package 第十五届模拟赛;publicclass problem01 {publicstaticvoidmain(String[] args){int ans =0;for(int i =1; i <=2023;++i){if(2023% i ==0){
ans++;System.out.println(i);}}System.out.println(ans);}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
2.
package 第十五届模拟赛;publicclass problem02 {publicstaticvoidmain(String[] args){int ans =0;for(int i =10; i <=100;++i){for(int j =0; j <=100;++j){if(i - j >=10){
ans++;}}}System.out.println(ans);}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
3.
package 第十五届模拟赛;publicclass problem03 {staticfinalintN=1000000;staticint[] p =newint[N+10];staticboolean[] vis =newboolean[N+10];staticint cnt =0;staticvoidisP(){for(int i =2; i * i <=N;++i){for(int j = i * i; j <=N; j += i){
vis[j]=true;}}}publicstaticvoidmain(String[] args){isP();int ans =0;for(int i =2; i <=N;++i){if(!vis[i]&&check(i)){
ans++;//System.out.println(i);}}System.out.println(ans);}staticbooleancheck(int n){int res =0;while(n >0){
res += n %10;
n /=10;}return res ==23;}}
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
27
28
29
30
31
32
33
34
35
4.
package 第十五届模拟赛;importjava.math.BigInteger;publicclass problem04 {publicstaticvoidmain(String[] args){BigInteger a =newBigInteger("12345678901234567890123456789012345678901234567890");BigInteger b =newBigInteger("2023");BigInteger mod = a.mod(b);System.out.println(mod);}}
1
2
3
4
5
6
7
8
9
10
11
12
13
5.
package 第十五届模拟赛;importjava.util.Scanner;publicclass problem05 {staticint[][] mp =newint[30][20];publicstaticvoidmain(String[] args){int n, m;
n =30; m =20;Scanner scanner =newScanner(System.in);for(int i =0; i < n;++i){for(int j =0; j < m;++j){
mp[i][j]= scanner.nextInt();}}int ans =0;int c =5, d =5;for(int i =0; i < n;++i){for(int j =0; j < m;++j){if(i + c > n || j + d > m){continue;}int tmp =0;for(int x = i; x < i + c;++x){for(int y = j; y < j + d;++y){
tmp += mp[x][y];}}
ans =Math.max(ans, tmp);}}System.out.println(ans);}}
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
27
28
29
30
31
32
33
34
35
6.
package 第十五届模拟赛;importjava.util.*;/**
* 小蓝要上一个楼梯,楼梯共有 n 级台阶(即小蓝总共要走 n 级)。小蓝每一步可以走 1 级、2 级或 3 级台阶。
* 请问小蓝至少要多少步才能上到楼梯顶端?
* 输入格式
* 输入一行包含一个整数 n 。
* 输出格式
* 输出一行包含一个整数,表示答案。
*/publicclass problem06 {staticfinalintN=10000+10;staticint[] f =newint[N];publicstaticvoidmain(String[] args){Scanner scanner =newScanner(System.in);int n = scanner.nextInt();
f[1]= f[2]= f[3]=1;for(int i =4; i <= n;++i){
f[i]=min(f[i -1], f[i -2], f[i -3])+1;}System.out.println(f[n]);}staticintmin(int a,int b,int c){int t =Math.min(a, b);returnMath.min(t, c);}}
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
27
28
29
30
7.
package 第十五届模拟赛;importjava.util.Scanner;publicclass problem07 {publicstaticvoidmain(String[] args){Scanner scanner =newScanner(System.in);String s = scanner.next();int ans =0;for(int i =0; i < s.length();++i){if((s.charAt(i)-'0')%2==1){
ans++;}}System.out.println(ans);}}
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
8.
package 第十五届模拟赛;importjava.util.Scanner;publicclass problem08 {staticfinalintN=1000+10;staticint[] a =newint[N];publicstaticvoidmain(String[] args){Scanner scanner =newScanner(System.in);int n = scanner.nextInt();for(int i =0; i < n;++i){
a[i]= scanner.nextInt();}int mx =Integer.MIN_VALUE, mi =Integer.MAX_VALUE;for(int i =1; i < n -1;++i){if(a[i]< a[i -1]&& a[i]< a[i +1]){
mx =Math.max(mx, a[i]);}if(a[i]> a[i -1]&& a[i]> a[i +1]){
mi =Math.min(mi, a[i]);}}System.out.println(mx +" "+ mi);}}
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
9.
package 第十五届模拟赛;importjava.util.Scanner;publicclass problem09 {staticfinalintN=1000+10;staticchar[][] mp =newchar[N][N];staticint[][] dir ={{1,0},{-1,-1},{-1,1}};staticint n, m;publicstaticvoidmain(String[] args){Scanner scanner =newScanner(System.in);
n = scanner.nextInt(); m = scanner.nextInt();for(int i =0; i < n;++i){
mp[i]= scanner.next().toCharArray();}int ans =0;int[][] a =newint[3][3];for(int i =1; i < n; i++){for(int j =1; j < m; j++){int cur_x = i, cur_y = j, cur_v = mp[i][j], tmp =0;for(int k =0; k <3;++k){// 三个方向初始化
a[k][0]= dir[k][0]+ i;
a[k][1]= dir[k][1]+ j;if(!check(a[k][0], a[k][1])){break;}
a[k][2]= mp[a[k][0]][a[k][1]];}while(check(a[0][0], a[0][1])&&check(a[1][0], a[1][1])&&check(a[2][0], a[2][1])&& mp[a[0][0]][a[0][1]]== mp[i][j]&& mp[a[1][0]][a[1][1]]== mp[i][j]&& mp[a[2][0]][a[2][1]]== mp[i][j]){// 三个坐标在范围内,并且三个值相同
tmp++;for(int k =0; k <3;++k){// 三个方向初始化
a[k][0]= dir[k][0]+ a[k][0];
a[k][1]= dir[k][1]+ a[k][1];if(!check(a[k][0], a[k][1])){break;}
a[k][2]= mp[a[k][0]][a[k][1]];}}
ans =Math.max(ans, tmp);}}System.out.println(ans);}staticbooleancheck(int x,int y){return!(x <0|| y <0|| x >= n || y >= m);}}
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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
10.
package 第十五届模拟赛;importjava.util.Scanner;publicclass problem10 {staticfinalintN=1000000+10;staticfinalintMOD=1000000007;staticint[] f =newint[N];publicstaticvoidmain(String[] args){Scanner scanner =newScanner(System.in);int n = scanner.nextInt();int a = scanner.nextInt();int b = scanner.nextInt();int c = scanner.nextInt();
f[a]= f[b]= f[c]=1;// a + bfor(int i = a +1; i <= n;++i){
f[i]=(f[i]+ f[i - a])%MOD;if(i >= b){
f[i]=(f[i]+ f[i - b])%MOD;}if(i >= c){
f[i]=(f[i]+ f[i - c])%MOD;}}System.out.println(f[n]%MOD);}}