# 15届蓝桥杯第三期模拟赛题单（C、J、P）

## 💯15届蓝桥杯第三期模拟赛题单（C、J、P）

### 1.奇数次数(题目编号:16565)

``````#include <iostream>
#include <cstring>
#include <string>
using namespace std;
char nums[10001] = {0};
int fun1(char ch)
{
return ch - '0';
}
int main()
{
int res = 0;
scanf("%s",nums);
int length = strlen(nums);
for (int i = 0; i < length; i++) {
int temp = fun1(nums[ i ]);
if (temp % 2) {
res++;
}
}
cout << res << endl;
return 0;
}
``````

### 2.台阶方案(题目编号:16566)

*方程：dp[i] [0] = dp [ i−a ] [3],dp[i] [1] = dp [ i−b ] [3],dp[i] [2] = dp [ i−c ] [3],dp[i] [3] = dp [ i ] [0] + dp [ i ] [1] +dp [ i ] [2] *

``````#include <iostream>
#include <cstring>
using namespace std;
int n,step[3];
int main()
{
cin >> n;
for (int i = 0; i < 3; i++) {
cin >> step[ i ];
}
int num[ n+1 ][4];
memset(num,0,sizeof(num));
for (int i = 0; i <= n; i++) {
for (int j = 0; j < 3; j++) {
if (i - step[ j ] == 0) {
num[ i ][ j ] = 1;
} else if (i - step[ j ] > 0) {
num[ i ][ j ] = num[ i-step[ j ] ][3];
}
}
for (int j = 0; j < 3; j++) {
num[ i ][3] += num[ i ][ j ];
num[ i ][3] %= 1000000007;
}
}
cout << num[ n ][3] << endl;
return 0;
}
``````

### 3.约数个数(题目编号:16574)

``````#include <iostream>
using namespace std;
int main()
{
//int res = 0;
//for (int i = 1; i <= 2023; i++) {
//if (2023 % i == 0) {
//res++;
//}
//}
//cout << res << endl;
cout << 6;
return 0;
}
``````

### 4.最大子矩阵(题目编号:16575)

``````9719 7515 5916 6467 7157 9614 8560 9075 2099 2838 1403 7652 6238 1699 8907 1804 5384 7942 7546 1978
8785 1944 8108 6040 2010 6646 2750 5410 4516 8757 5624 9257 9030 9290 6833 4646 9749 5304 5633 1573
8525 8244 8514 7474 7896 9731 8402 9036 1869 2688 2085 1667 7753 8466 4911 3812 8585 8319 4020 7350
1949 9120 4424 4057 8277 4511 6333 1533 7624 8932 1053 8682 9284 4134 1466 3607 8753 5310 3728 4163
9420 9185 7055 2342 4143 4499 2036 5374 7026 8638 8866 8364 1706 8767 1601 8309 5695 8179 4142 8489
5876 5660 4658 8307 2582 7544 8793 8207 3979 1692 1400 1893 4500 6389 7198 4836 4761 6603 2859 1312
6367 4174 9956 6668 6771 4795 6492 3937 7096 8041 8644 9379 8071 8667 5810 5794 8147 3823 7877 4822
4809 3297 8518 4972 9754 6854 3271 7891 8882 1052 3197 6035 5628 7674 7931 8085 8970 7733 4745 8785
7536 1511 6964 4763 5409 7032 8963 8576 3411 5853 3316 1267 7851 2735 6953 2970 1810 6830 5576 6903
2241 1575 2379 4679 9519 9290 4802 1562 3509 8365 6777 5143 5610 1061 7880 1935 5793 7023 5629 9571
2480 5937 4612 8890 1964 8532 3309 9737 8507 1849 8544 1500 9282 6288 2137 4730 4239 3473 4643 6377
7341 2881 3430 5815 1972 6629 3817 4547 7561 4779 6578 6114 4972 5505 7515 1800 4784 2272 4502 7541
7665 8607 2022 8192 2605 1346 4155 8725 8167 7022 6136 3615 6057 6329 8671 2033 3151 2249 5981 6412
9046 3353 8650 6965 4179 1248 5659 5219 8083 5615 3821 4436 9217 7356 3914 5717 3734 3765 4435 7210
8951 5013 2951 7401 2329 5686 6530 9581 6539 6881 8634 2663 2916 3019 8529 5645 8201 9270 1939 7275
6429 1531 6322 9586 2793 7968 4001 9665 7624 4369 6245 5146 9567 6801 6064 6199 3210 6753 2586 7795
5771 8507 7973 1470 1475 6896 6781 6572 8412 8557 8255 5268 8960 7251 9214 2489 6920 9917 3810 4605
9116 7950 3715 1697 4703 2868 8673 3106 2579 1074 3992 3547 4279 3149 3396 6081 6221 1125 9358 2471
8360 1526 4116 9278 6325 5175 5533 4107 7522 7599 7711 9211 1752 2431 8321 3844 3579 1047 3987 8487
7600 2401 8748 8945 2078 1519 4614 4576 5706 4040 9358 1928 1327 6699 5258 2846 3418 8310 1249 3866
7796 8668 4087 4258 8992 8996 4617 5997 2527 8204 8927 1456 9340 2088 1605 2299 9878 8347 7789 2122
8372 1102 4243 4208 1651 7861 4947 7802 4704 6204 4455 6012 8494 9060 3747 2786 2136 1830 7424 8309
6919 4420 2031 5399 2652 7219 4048 7013 5094 5276 4225 5976 4157 6722 8765 4679 1604 4986 5033 2623
4015 2297 3067 6261 6623 4577 4589 4747 6659 7667 7853 4040 6393 9606 7219 9334 1316 3430 9963 5187
4998 3735 9884 2990 1374 8436 6674 3018 5714 9352 8708 8789 7879 2965 1444 4671 4743 9817 6066 8057
6996 9609 2884 4601 7287 3432 4145 8858 6857 8624 4531 6579 1615 2894 4521 3274 5237 1093 3317 9289
7117 1850 3210 8010 2512 1394 4718 9332 5593 4118 4995 3994 5063 9426 1709 5128 4997 9287 1907 9068
4258 7328 6490 2603 5333 5093 8070 2116 8489 1994 7098 7409 1463 4268 9509 2358 1192 2460 5031 6292
4911 1192 1012 2494 5276 8981 3540 3306 8869 6678 7879 7526 8847 6270 7653 3109 6955 9760 8520 8673
6328 7277 7818 3285 9398 4929 4639 1617 4023 1051 9320 4955 6580 6481 3824 9611 2863 6492 6281 6203
``````
``````#include <iostream>
using namespace std;
// int nums[30][20] = {0};
// int fun(int i, int j)
// {
//     int res = 0;
//     for (int p = 0; p < 5; p++) {
//         for (int q = 0; q < 5; q++) {
//             res += nums[i+p][j+q];
//         }
//     }
//     return res;
// }
int main()
{
// int i,j,maxRes = 0;
// for (i = 0; i < 30; i++) {
//     for (j = 0; j < 20; j++) {
//         cin >> nums[i][j];
//     }
// }
// for (i = 0; i < 25; i++) {
//     for (j = 0; j < 15; j++) {
//         int temp = fun(i,j);
//         maxRes = max(maxRes,temp);
//     }
// }
// cout << maxRes << endl;
cout << 171248;
return 0;
}
``````

### 5.最少步数(题目编号:16569)

``````#include <iostream>
using namespace std;
int main()
{
int n,res,temp;
cin >> n;
temp = n % 3;
if (!temp) {
res = n / 3;
} else {
res = n / 3 + 1;
}
cout << res << endl;
return 0;
}
``````

### 6.最大极小值与最小极大值(题目编号:16568)

``````#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int main()
{
vector<int> minNums;
vector<int> maxNums;
int n;
cin >> n;
int nums[ n ];
for(int i = 0; i < n; i++) {
cin >> nums[ i ];
}
for (int i = 1; i < n - 1; i++) {
if (nums[i-1] < nums[i] &&
nums[i] > nums[i+1]) {
maxNums.push_back(nums[i]);
} else if (nums[i-1] > nums[i] &&
nums[i] < nums[i+1]) {
minNums.push_back(nums[i]);
}
}
sort(minNums.begin(),minNums.end());
sort(maxNums.begin(),maxNums.end());
int size = minNums.size();
cout << minNums[ size-1 ] << " " << maxNums[0] << endl;
return 0;
}
``````

**时间复杂度(由极大值或极小值组成的数组大小小故不考虑)：O(n) **

### 7.最大的Y(题目编号:16567)

``````#include <iostream>
using namespace std;
char matrix[1001][1001] = {0};
int n,m;
int fun(int i,int j,char ch)
{
int res = 0;
if (i <= 1 || j <= 1 || i >= n || j >= m) {
return 0;
}
for (int p = 1; ;p++) {
if (matrix[i-p][j-p] == ch &&
matrix[i-p][j+p] == ch &&
matrix[i+p][ j ] == ch) {
res++;
} else {
break;
}
if (i-p <= 1 || i+p >= n || j-p <= 1 || j+p >= m) {
break;
}
}
return res;
}
int main()
{
int res = 0;
cin >> n;
cin >> m;
for (int i = 1; i <= n; i++) {
for (int j = 1; j <= m; j++) {
cin >> matrix[i][j];
}
}
for (int i = 2; i <= n; i++) {
for (int j = 2; j <= m; j++) {
int temp = fun(i,j,matrix[i][j]);
res = res>temp?res:temp;
}
}
cout << res << endl;
return 0;
}
``````

### 8.求余数(题目编号:16571)

``````print(1234567890123456789012345678901234567890 % 2023)
``````
``````#include <iostream>
#include <queue>
using namespace std;
int fun1(char num)
{
return num-'0';
}
int main()
{
char numTemp[51] = {"12345678901234567890123456789012345678901234567890"};
queue<int> num;
for (int i = 0; i < 50; i++) {
int temp = fun1(numTemp[i]);
num.push( temp );
}
int num1 = 0;
for (int i = 0; i < 3; i++) {
num1 = num1 * 10 + num.front();
num.pop();
}
bool empty = num.empty();
while (!empty) {
num1 *= 10;
num1 += num.front();
num.pop();
empty = num.empty();
num1 %= 2023;
}
cout << num1 << endl;
system("pause");
return 0;
}
``````

### 9.数位和(题目编号:16573)

``````#include <iostream>
using namespace std;
int nums[1000001] = {0};
//判断题意
bool fun2(int num)
{
int res = 0;
while (num != 0) {
res += (num % 10);
num /= 10;
}
if (res == 23) {
return true;
}
return false;
}
//筛法搜索质数
int fun1()
{
int res = 0;
for (int i = 2; i <= 1000000; i++) {
if (nums[ i ]) {
continue;
}
if ( fun2(i) ) {
res++;
}
int temp = 2 * i;
while (temp <= 1000000) {
nums[ temp ] = 1;
temp += i;
}
}
return res;
}
int main()
{
int res = fun1();
cout << res << endl;
return 0;
}
``````

### 10.区间计数(题目编号:16572)

``````#include <iostream>
using namespace std;
int main()
{
//int res = 0;
//for (int l = 0; l <= 100; l++) {
//for (int r = 0; r <= 100; r++) {
//if (r - l >= 10) {
//res++;
//}
//}
//}
//cout << res << endl;
cout << 4186;
return 0;
}
``````

### 11.左右相同(题目编号:16570)

``````#include <iostream>
#include <cstring>
#include <string>
using namespace std;
int main()
{
string str;
cin >> str;
int size = str.length(),ans = 0;
int num[2] = {0};
for (int i = 0; i < size; i++) {
if (str[ i ] == 'L') {
num[ 0 ]++;
} else {
num[ 1 ]++;
}
if (num[ 0 ] == num[ 1 ]) {
ans++;
}
}
cout << ans << endl;
return 0;
}
``````

THE END