跳到正文

个人记录

26暑假二期晚上J2训练课-河西廖总结

farong约 6 分钟
原文
文章信息与版本

文章信息

收录
2026年7月28日
更新
2026年7月28日
篇幅
约 6 分钟

版本

  1. v1当前

26暑假二期晚上J2训练课-河西廖总结

得分情况与用时

T1: 100分

T2: 100分

T3: 40分

T4: 70分

T5: 50分

T1题目解析

题意

给定一个数x求x%2023的非负结果。

思路

很简单数学题,按规则写出算式就好了。

代码

C++
#include<bits/stdc++.h>
#define int long long
using namespace std;

int n;

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	cin>>n;
	if(n>=0){
		cout<<n%2023;
	}else{
		cout<<2023-(abs(n)%2023);
	}
	return 0;
}

个人总结

很简单的一个题,直接缪杀,好题多出。

T2题目解析

题意

在数字 2,6,9,0 中有一个零的影子,而在数字 8 中有两个零的影子。给出一个数,求其中零的影子的个数。

思路

做if判断。

代码

C++
#include<bits/stdc++.h>
#define int long long
using namespace std;

int cnt;
string s;

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	cin>>s;
	for(int i=0;i<=s.size();i++){
		if(s[i]=='0'||s[i]=='2'||s[i]=='6'||s[i]=='9'){
			cnt++;
		}else if(s[i]=='8'){
			cnt+=2;
		}
	}
	cout<<cnt;
	return 0;
}

个人总结

很简单的题,并不难。

T3题目解析

题意

给我们一个时间求在此之后(不包含此时刻)的第一个回文时间

思路

用循环列举时间。

代码

C++
#include<bits/stdc++.h>
#define int long long
using namespace std;

char s;
int n,m;

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	cin>>n>>s>>m;
	while(1){
        m++;
		if(m>=60) m=0,n++;
		if(n>=24) n=0;
		int mq,mh,nq,nh;
		mq=m/10,mh=m%10,nq=n/10,nh=n%10;
		if(mq==nh&&mh==nq){
			cout<<nq<<nh<<":"<<mq<<mh;
			break;
		}
	}
	return 0;
}

个人总结

这题只拿了20分,当时没想到枚举。

T4题目解析

题意

给我们n个数,其中有多少个数,恰好等于集合中另外两个(不同的)数之和?

思路

做循环枚举数字,在用桶标记。

代码

C++
#include<bits/stdc++.h>
#define int long long
using namespace std;

int n,a[105],cnt,t[20005];

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	for(int i=1;i<=n;i++){
		for(int x=1;x<=n;x++){
			for(int y=1;y<=n;y++){
				if(a[i]+a[x]==a[y]&&i!=x&&x!=y&&t[a[y]]==0){
					cnt++;
                    t[a[y]]=1;
				}
			}
		}
		
	}
	cout<<cnt;
	return 0;
}

个人总结

这题只拿了70分,T4桶数组开小了。T4起始点本际司导致城的最重复计数,边界检查顺中错

T5题目解析

题意

给一个人的坐标,移动次数k,地图(由‘.’和‘x’组成),朝向,如果朝这个方向走会超过地图或到‘x’,那么向右转,在机器人执行完 k 步操作之后,地图上所有被机器人经过的位置(包括起始位置)有几个。

思路

做循环把每次操作列举出来,如果可以走,更新 x,y,检查是否被标记过,没被标记cnt++,最后输出。

代码

C++
#include<bits/stdc++.h>
#define int long long
using namespace std;

int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
char a[1005][1005];
int vis[1005][1005];

signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	int t;
	cin>>t;
	while(t--){
		memset(vis,0,sizeof(vis));
		int n,m,k,x,y,d;
		cin>>n>>m>>k>>x>>y>>d;
		int cnt=1;
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++){
				cin>>a[i][j];
			}
		}
		while(k--){
			vis[x][y]=1;
			int nx=x+dx[d];
			int ny=y+dy[d];
			if(nx>=1&&nx<=n&&ny>=1&&ny<=m&&a[nx][ny]=='.'){
				if(vis[nx][ny]==0) cnt++;
				x=nx;
				y=ny;
			}else{
				d=(d+1)%4;
			}
		}
		cout<<cnt<<endl;
	}
	return 0;
}

个人总结

这题有点难当时没想到可以用dx.dy用了很多数组。

整场考试总结

题目理解能力还行但对知识点的掌控不太熟练。

原文