跳到正文

个人记录

8.23-407-模拟考

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

文章信息

发布
2025年8月23日
收录
2025年12月12日
更新
2026年11月11日
篇幅
约 3 分钟

版本

  1. v1当前

8.23-407-模拟考

T1 高铁线路

题意简化

给你三个数,X,Y,ZX,Y,Z让你求出ZZ是否在X,YX,Y的中间。

代码

C++
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
int n,x,y,z;
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>x>>y>>z;
	if((x<z&&z<y)||(y<z&&z<x)){
		cout<<"Yes";
	}else{
		cout<<"No";
	}
	return 0;
}

T2 Peter 的烟

题意简化

给你一个nn和kk,让你求出可以用kk换1是可以抽多少烟。

题意分析

我们模拟每一次抽烟的过程,每多抽一更烟,就会少kk个烟蒂,但又会获得一个烟蒂。

代码

C++
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
int n,k;
int ans;
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>k;
	int ts=n;
	ans+=n;
	while(ts>=k){
		if(ts>=k){
			ans++;
			ts-=k;
			ts++;
		}
	} 
	cout<<ans;
	return 0;
}

T3 Int128 游乐园

题意分析

有nn个队伍,每个队伍有aia_i个人,设备能载kk个人。我们只要不停的判断能不能装下下一个队伍即可。

代码

C++
#include<bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;
const int N=105;
int n,k;
int a[N];
int ans;
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int tmp=a[1];
	for(int i=2;i<=n;i++){
		if(tmp+a[i]<=k){
			tmp+=a[i];
		}else{
			tmp=a[i];
			ans++;
		} 
	} 
	cout<<ans+1;
	return 0;
}

T4 五子棋

做过原题,且写过总结,就不多说了。死因主要是时间不够没写出正解。

原题总结在这里的7.26篇的T1。

原文