题解归档 - cf2233A
本文最后由方少年更新于2026 年 6 月 28 日,已超过0天没有更新。如果文章内容或图片资源失效,请留言反馈,将会及时处理,谢谢!
题解归档 - cf2233A
本文由 cf-code 本地题解库自动归档;公开内容以本地 AC/验证版本为准。
- 本地编号:
cf2233A - 本地来源:
problems/cf2233A/idea.md - 题目链接:https://codeforces.com/contest/2233/problem/A
- 原始标题:cf2233A - AI Project Development
思路
cf2233A - AI Project Development
pattern:
ceil division / compare two fixed strategies
claim:
Nikita has only two strategies, and each strategy has a deterministic
completion time measured in full hours.
formulas:
- No AI: both write from hour
0, speed isx+y, so time isceil(n/(x+y)). - AI: during the first
zhours only Maxim writes. Ifx*z >= n, the project
finishes during setup inceil(n/x)hours. Otherwise, after setup there aren-x*zlines left and the speed isx+10*y, so time isz + ceil((n-x*z)/(x+10*y)).
answer:
Take the minimum of the two times.
check:brute.cpp simulates full hours for both choices on small and random values.
代码
来源:problems/cf2233A/solution.cpp
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll ceilDiv(ll a,ll b){
return (a+b-1)/b;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T;
cin>>T;
while(T--){
ll n,x,y,z;
cin>>n>>x>>y>>z;
ll noAi=ceilDiv(n,x+y);
ll withAi;
if(x*z>=n) withAi=ceilDiv(n,x);
else withAi=z+ceilDiv(n-x*z,x+10*y);
cout<<min(noAi,withAi)<<"\n";
}
return 0;
}
~ ~ The End ~ ~
文章标题:题解归档 - cf2233A
文章链接:https://www.fangshaonian.cn/archives/289/
最后编辑:2026 年 6 月 28 日 19:06 By 方少年
许可协议: 署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)