跳到正文

生活·游记

ZMOI普及比赛做题笔记

LIUYIFAN5约 3 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年5月22日
篇幅
约 3 分钟

版本

  1. v1当前

比赛前一天

打了nn个搜索(累死)

比赛了

看到C题(判断素数)?

立马A了

C++
#include<bits/stdc++.h>
using namespace std;
 int n;
bool pdss(int x){
	if(x==2)return 1;
	for(int i=2;i*i<=x;i++){
		if(x%i==0)return 0;
	}
	return 1;
}
int main(){
	cin>>n;
	if(pdss(n)==1)cout<<"Yes";
	else cout<<"No" ;
}

接着看B题(金币)?

秒了

C++
#include<bits/stdc++.h>
using namespace std;
int n;
long long ans,zc;
int main(){
	cin>>n;
	for(int i=1;;i++){
		for(int j=1;j<=i;j++){
			ans+=i;
			zc++;
			if(zc==n){
				cout<<ans;
				return 0;
			}
		}
	}
}

打俩循环A了(送分啊)

俩题做完15分钟

此时的我正看着A题,找规律

忽然发现规律(输出的是和mod2mod 2啊!)

秒了

C++
#include<bits/stdc++.h>
using namespace std;
int n;
int ans;
int main(){
	cin>>n;
	for(int i=1;i<=n;i++){
		ans+=i;
	}
	int k=ans%2;
	cout<<k;
}

做完三道还剩两个半小时(此时的 @shooting__star 在干什么呢?)

同桌 @wangshenluogu 也A了前三题

这时

我惊人的发现,D题可以输出0骗40分(好开心偶 立马骗到

然后,用dfs

A掉了E题

C++
#include<bits/stdc++.h>
using namespace std;
char ch;
int n,m;
char a[45][45];
int sx,sy,v[45][45],step,k,ans;
int dx[4]={0,0,1,-1};
int dy[4]={-1,1,0,0};
void dfs(int x,int y){
	for(int i=0;i<4;i++){
		int nx=x+dx[i];
		int ny=y+dy[i];
		if(nx>=1&&nx<=m&&ny>=1&&ny<=n&&a[nx][ny]=='.'){
			ans++;
			a[nx][ny]='#';
			dfs(nx,ny);
		}
	}
	return ;
}
int main(){

	cin>>n>>m;
	for(int i=1;i<=m;i++){
		for(int j=1;j<=n;j++){
			cin>>a[i][j];
			if(a[i][j]=='@'){
				sx=i;
				sy=j;
			}
		}
	}
	dfs(sx,sy);
	cout<<ans+1;
}

此时还剩2小时,最后2题

一题动规我不会

一题调了一个半小时调不出依旧爆0

直接摆烂

最后还拿了第5!

虽然前四都是提高班或是外网的,所以,实质上是我是第一(虽然有7,8个440分第五的)

并列第一

哈哈(但我还是太不行了,700分才拿440)

原文