开始整卷作答
按大题分页,翻页自动存草稿,做完统一交卷。
## 一、单项选择题(共15题,每题2分,共计30分)
第 1–15 题 · 共 15 题
## 二、阅读程序(判断题1分,选择题3分,共计40分)
判断题正确填 `T`,错误填 `F`。
### 第1题
```cpp
#include<iostream>
int main() {
int n;
std::cin >> n;
long long s = 1;
int i = 2;
while (i*i < n) {
if (n % i == 0) {
s += i;
s += n / i;
}
++i;
}
if (i*i == n) s += i;
if (s < n)
std::cout << "Deficient\n";
else if (s > n)
std::cout << "Abundant\n";
else
std::cout << "Perfect\n";
}
```
第 16–20 题 · 共 5 题
### 第2题
```cpp
#include<iostream>
int main()
{
int q[2000] = {10};
int s[2000] = {0};
int size = 1;
char c;
while (std::cin >> c) {
int d = c - '0';
int r = 0;
for (int i = 0; i < size; ++i) {
r = r * 10 + q[i];
q[i] = r / 8;
r = r % 8;
}
while (r > 0) {
r = r * 10;
q[size] = r / 8;
size++;
r = r % 8;
}
for (int i = 0; i < size; ++i)
s[i] += q[i] * d;
for (int i = size; i > 0; --i) {
s[i-1] += s[i] / 10;
s[i] %= 10;
}
}
while (size > 0 and s[size-1] == 0)
size --;
for (int i = 0; i < size; ++i)
std::cout << s[i];
std::cout << "\n";
}
```
第 21–27 题 · 共 7 题
### 第三题
```cpp
#include<iostream>
const int mod = 1000000007;
int exp();
int term()
{
char dummy;
std::cin >> dummy;
int t = exp();
std::cin >> dummy;
if (t == 0) return 1;
else return t*2 % mod;
}
int exp()
{
int result = 0;
while (std::cin.peek() == '(')
{
result += term();
result %= mod;
}
return result;
}
int main()
{
std::cout << exp();
}
```
第 28–35 题 · 共 8 题
## 三、完善程序(单选题,每小题3分,共计30分)
### 第1题
两人进行 $n$ 次石头剪刀布游戏,给定对方的出拳序列,由 `R`、`S`、`P` 组成(分别表示石头、剪刀、布)。你的出拳需满足:从未输过(每次非赢即平);相邻两次出拳不同。求可能赢的最大对局数(即赢的次数,平局不计入)。
```cpp
#include<iostream>
int score(int a,int b){
if(____(1)____) return 0;
else if(a=='R' and b=='S')return 1;
else if(____(2)____)return 1;
else if(a=='P' and b=='R')return 1;
else return -10000000;
}
int main(){
____(3)____ ;
int n;
std::cin>>n;
while(n-->0){
char c;
std::cin>>c;
int newR = ____(4)____ ;
int newS = ____(5)____ ;
int newP = ____(6)____ ;
R=newR;
S=newS;
P=newP;
}
std::cout<<std::max(std::max(R,S),P);
}
```
第 36–39 题 · 共 4 题
### 第2题
给定 $n\times n$ 个方格构成的矩阵,刷满了红色和蓝色。现在要矩阵的一些格子刷上紫色,使得矩阵同时满足以下两个条件:从 $(1,1)$ 走到 $(n,n)$,保证存在一条路径使其只经过红色和紫色;从 $(1,n)$ 走到 $(n,1)$,保证存在一条路径使其只经过蓝色和紫色。注意,行动时只可以往任何一个方向前进,至少要将多少格子刷成紫色才能使以上两个条件成立呢?
```cpp
#include<iostream>
#include<deque>
int n;
const int maxn = 500;
char c[maxn][maxn];
int dist[maxn][maxn];
int solve(int sx, int sy, int tx, int ty, char color) {
bool visited[maxn][maxn] = {false};
std::deque<std::pair<int, int>> q;
q.push_back({sx, sy});
visited[sx][sy] = true;
____(1)____ ;
while (!q.empty()) {
int x = q.front().first;
int y = q.front().second;
q.pop_front();
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
for (int k = 0; k < 4; ++k) {
int nx = x + dx[k];
int ny = y + dy[k];
if (0 <= nx and nx < n and 0 <= ny and ny < n) {
if (not visited[nx][ny]) {
visited[nx][ny] = true;
if ( ____(2)____ ) {
dist[nx][ny] = dist[x][y];
q.push_front({nx, ny});
}
else {
dist[nx][ny] = ____(3)____ ;
q.push_back({nx, ny});
}
}
}
}
}
return ____(4)____ ;
}
int main()
{
std::cin >> n;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
std::cin >> c[i][j];
}
}
std::cout << ____(5)____ + ____(6)____ << "\n";
}
```
第 40–45 题 · 共 6 题
展开逐题清单(单独练某一道)
● 绿=已通过 ● 橙=做过没全对 ● 灰=没做过
## 一、单项选择题(共15题,每题2分,共计30分)
1.
珅泽教育CSP-J第一轮模拟考第四套 第 1 题
2.
珅泽教育CSP-J第一轮模拟考第四套 第 2 题
3.
珅泽教育CSP-J第一轮模拟考第四套 第 3 题
4.
珅泽教育CSP-J第一轮模拟考第四套 第 4 题
5.
珅泽教育CSP-J第一轮模拟考第四套 第 5 题
6.
珅泽教育CSP-J第一轮模拟考第四套 第 6 题
7.
珅泽教育CSP-J第一轮模拟考第四套 第 7 题
8.
珅泽教育CSP-J第一轮模拟考第四套 第 8 题
9.
珅泽教育CSP-J第一轮模拟考第四套 第 9 题
10.
珅泽教育CSP-J第一轮模拟考第四套 第 10 题
11.
珅泽教育CSP-J第一轮模拟考第四套 第 11 题
12.
珅泽教育CSP-J第一轮模拟考第四套 第 12 题
13.
珅泽教育CSP-J第一轮模拟考第四套 第 13 题
14.
珅泽教育CSP-J第一轮模拟考第四套 第 14 题
15.
珅泽教育CSP-J第一轮模拟考第四套 第 15 题
## 二、阅读程序(判断题1分,选择题3分,共计40分)
判断题正确填 `T`,错误填 `F`。
### 第1题
```cpp
#include<iostream>
int main() {
int n;
std::cin >> n;
long long s = 1;
int i = 2;
while (i*i < n) {
if (n % i == 0) {
s += i;
s += n / i;
}
++i;
}
if (i*i == n) s += i;
if (s < n)
std::cout << "Deficient\n";
else if (s > n)
std::cout << "Abundant\n";
else
std::cout << "Perfect\n";
}
```
16.
珅泽教育CSP-J第一轮模拟考第四套 第 16 题
17.
珅泽教育CSP-J第一轮模拟考第四套 第 17 题
18.
珅泽教育CSP-J第一轮模拟考第四套 第 18 题
19.
珅泽教育CSP-J第一轮模拟考第四套 第 19 题
20.
珅泽教育CSP-J第一轮模拟考第四套 第 20 题
### 第2题
```cpp
#include<iostream>
int main()
{
int q[2000] = {10};
int s[2000] = {0};
int size = 1;
char c;
while (std::cin >> c) {
int d = c - '0';
int r = 0;
for (int i = 0; i < size; ++i) {
r = r * 10 + q[i];
q[i] = r / 8;
r = r % 8;
}
while (r > 0) {
r = r * 10;
q[size] = r / 8;
size++;
r = r % 8;
}
for (int i = 0; i < size; ++i)
s[i] += q[i] * d;
for (int i = size; i > 0; --i) {
s[i-1] += s[i] / 10;
s[i] %= 10;
}
}
while (size > 0 and s[size-1] == 0)
size --;
for (int i = 0; i < size; ++i)
std::cout << s[i];
std::cout << "\n";
}
```
21.
珅泽教育CSP-J第一轮模拟考第四套 第 21 题
22.
珅泽教育CSP-J第一轮模拟考第四套 第 22 题
23.
珅泽教育CSP-J第一轮模拟考第四套 第 23 题
24.
珅泽教育CSP-J第一轮模拟考第四套 第 24 题
25.
珅泽教育CSP-J第一轮模拟考第四套 第 25 题
26.
珅泽教育CSP-J第一轮模拟考第四套 第 26 题
27.
珅泽教育CSP-J第一轮模拟考第四套 第 27 题
### 第三题
```cpp
#include<iostream>
const int mod = 1000000007;
int exp();
int term()
{
char dummy;
std::cin >> dummy;
int t = exp();
std::cin >> dummy;
if (t == 0) return 1;
else return t*2 % mod;
}
int exp()
{
int result = 0;
while (std::cin.peek() == '(')
{
result += term();
result %= mod;
}
return result;
}
int main()
{
std::cout << exp();
}
```
28.
珅泽教育CSP-J第一轮模拟考第四套 第 28 题
29.
珅泽教育CSP-J第一轮模拟考第四套 第 29 题
30.
珅泽教育CSP-J第一轮模拟考第四套 第 30 题
31.
珅泽教育CSP-J第一轮模拟考第四套 第 31 题
32.
珅泽教育CSP-J第一轮模拟考第四套 第 32 题
33.
珅泽教育CSP-J第一轮模拟考第四套 第 33 题
34.
珅泽教育CSP-J第一轮模拟考第四套 第 34 题
35.
珅泽教育CSP-J第一轮模拟考第四套 第 35 题
## 三、完善程序(单选题,每小题3分,共计30分)
### 第1题
两人进行 $n$ 次石头剪刀布游戏,给定对方的出拳序列,由 `R`、`S`、`P` 组成(分别表示石头、剪刀、布)。你的出拳需满足:从未输过(每次非赢即平);相邻两次出拳不同。求可能赢的最大对局数(即赢的次数,平局不计入)。
```cpp
#include<iostream>
int score(int a,int b){
if(____(1)____) return 0;
else if(a=='R' and b=='S')return 1;
else if(____(2)____)return 1;
else if(a=='P' and b=='R')return 1;
else return -10000000;
}
int main(){
____(3)____ ;
int n;
std::cin>>n;
while(n-->0){
char c;
std::cin>>c;
int newR = ____(4)____ ;
int newS = ____(5)____ ;
int newP = ____(6)____ ;
R=newR;
S=newS;
P=newP;
}
std::cout<<std::max(std::max(R,S),P);
}
```
36.
珅泽教育CSP-J第一轮模拟考第四套 第 36 题
37.
珅泽教育CSP-J第一轮模拟考第四套 第 37 题
38.
珅泽教育CSP-J第一轮模拟考第四套 第 38 题
39.
珅泽教育CSP-J第一轮模拟考第四套 第 39 题
### 第2题
给定 $n\times n$ 个方格构成的矩阵,刷满了红色和蓝色。现在要矩阵的一些格子刷上紫色,使得矩阵同时满足以下两个条件:从 $(1,1)$ 走到 $(n,n)$,保证存在一条路径使其只经过红色和紫色;从 $(1,n)$ 走到 $(n,1)$,保证存在一条路径使其只经过蓝色和紫色。注意,行动时只可以往任何一个方向前进,至少要将多少格子刷成紫色才能使以上两个条件成立呢?
```cpp
#include<iostream>
#include<deque>
int n;
const int maxn = 500;
char c[maxn][maxn];
int dist[maxn][maxn];
int solve(int sx, int sy, int tx, int ty, char color) {
bool visited[maxn][maxn] = {false};
std::deque<std::pair<int, int>> q;
q.push_back({sx, sy});
visited[sx][sy] = true;
____(1)____ ;
while (!q.empty()) {
int x = q.front().first;
int y = q.front().second;
q.pop_front();
const int dx[4] = {1, -1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
for (int k = 0; k < 4; ++k) {
int nx = x + dx[k];
int ny = y + dy[k];
if (0 <= nx and nx < n and 0 <= ny and ny < n) {
if (not visited[nx][ny]) {
visited[nx][ny] = true;
if ( ____(2)____ ) {
dist[nx][ny] = dist[x][y];
q.push_front({nx, ny});
}
else {
dist[nx][ny] = ____(3)____ ;
q.push_back({nx, ny});
}
}
}
}
}
return ____(4)____ ;
}
int main()
{
std::cin >> n;
for (int i = 0; i < n; ++i) {
for (int j = 0; j < n; ++j) {
std::cin >> c[i][j];
}
}
std::cout << ____(5)____ + ____(6)____ << "\n";
}
```
40.
珅泽教育CSP-J第一轮模拟考第四套 第 40 题
41.
珅泽教育CSP-J第一轮模拟考第四套 第 41 题
42.
珅泽教育CSP-J第一轮模拟考第四套 第 42 题
43.
珅泽教育CSP-J第一轮模拟考第四套 第 43 题
44.
珅泽教育CSP-J第一轮模拟考第四套 第 44 题
45.
珅泽教育CSP-J第一轮模拟考第四套 第 45 题