专栏文章

题解:P14505 [NCPC 2025] km/h

P14505题解参与者 3已保存评论 2

文章操作

快速查看文章及其快照的属性,并进行相关操作。

当前评论
2 条
当前快照
1 份
快照标识符
@min8h7oq
此快照首次捕获于
2025/12/01 22:17
3 个月前
此快照最后确认于
2025/12/01 22:17
3 个月前
查看原文
简单模拟题。每次遇到限速时直接输出限速,同时用一个变量维护国家限速,具体的,若当前限速为 aa,则更新国家限速为当前国家限速与首个大于 aa 且能够被 1010 整除的数。当遇到解除限速时,输出国家限速即可。马蜂良好

代码如下:

CPP
#include<bits/stdc++.h>
#define int long long

using namespace std;
int n,a,maxn;
string s;

inline int pre()
{
	int l=s.size(),res=0;
	for(int i=0;i<l;i++)(res*=10)+=s[i]-'0';
	return res;
}

inline int find()
{
	int res=a;
	(res+=10)-=res%10;
	return res;
}

signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cin>>n;
	while(n--)
	{
		cin>>s;
		if(s[0]=='/')cout<<maxn<<"\n";
		else
		{
			cout<<s<<"\n";
			a=pre();
			maxn=max(maxn,find());
		}
	}
	return 0;
}

评论

2 条评论,欢迎与作者交流。

正在加载评论...