专栏文章
【HT-051-Div.4】核桃新手组周赛个人题解
题解参与者 1已保存评论 0
文章操作
快速查看文章及其快照的属性,并进行相关操作。
- 当前评论
- 0 条
- 当前快照
- 1 份
- 快照标识符
- @mipufqj7
- 此快照首次捕获于
- 2025/12/03 18:07 3 个月前
- 此快照最后确认于
- 2025/12/03 18:07 3 个月前
0.序言
逆天T1爆了。全场几乎全是模拟。
95+100+100+100=395
T1
分类讨论。
第一个问题较简单,若 则答案为 ,否则答案为 ,即答案为 。最少给仅一块土地反复浇水,答案为 。
第二个问题,一共能给 块土地浇水,答案为 。如果 ,那么至少会有一块土地被重复浇水,答案为 ,否则答案为 。
时间复杂度 。
CPP#include <bits/stdc++.h>
using namespace std;
int main()
{
int n, m;
cin >> n >> m;
cout << min(m,n) << " " << 1 << endl;
cout << min(m / 2, n) << " " << (m > n)?1:0;
return 0;
}
T2
模拟即可(真没什么好讲的),时间复杂度 。
CPP#include <bits/stdc++.h>
using namespace std;
int n, x;
int main()
{
cin>>n;
while(cin>>x)
{
if (x>=n)
{
cout<<n;
return 0;
}
n+=x;
}
cout<<n;
}
T3
模拟即可。循环维护最大值。时间复杂度 。
CPP#include <bits/stdc++.h>
using namespace std;
int t, x, maxn = -1;
string s, maxs;
int main()
{
cin>>t;
while(t--)
{
cin>>s>>x;
if (x>maxn)
{
maxs=s;
maxn=x;
}
}
cout<<maxs;
}
T4
模拟即可。(怎么全是模拟)
CPP#include <bits/stdc++.h>
using namespace std;
int t;
string l;
int main()
{
while (cin>>t)
{
if (t==99999) return 0;
int s1 = t/10000,s2=(t/1000)%10;
if ((s1+s2)%2==1)cout<<"left "<<t%1000,l="left ";
else if (s1+s2!=0)cout<<"right "<<t%1000,l="right ";
else cout<<l<<t%1000;
cout<<endl;
}
}
相关推荐
评论
共 0 条评论,欢迎与作者交流。
正在加载评论...