题解归档 - cf2233A

题解归档 - cf2233A

本文由 cf-code 本地题解库自动归档;公开内容以本地 AC/验证版本为准。

思路

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 is x+y, so time is
    ceil(n/(x+y)).
  • AI: during the first z hours only Maxim writes. If x*z >= n, the project
    finishes during setup in ceil(n/x) hours. Otherwise, after setup there are
    n-x*z lines left and the speed is x+10*y, so time is
    z + 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  ~  ~


 赏 
感谢您的支持,我会继续努力哒!
支付宝收款码
tips
文章二维码 分类标签:归档TypechoAutoUpload
文章标题:题解归档 - cf2233A
文章链接:https://www.fangshaonian.cn/archives/289/
最后编辑:2026 年 6 月 28 日 19:06 By 方少年
许可协议: 署名-非商业性使用-相同方式共享 4.0 国际 (CC BY-NC-SA 4.0)
(*) 8 + 6 =
快来做第一个评论的人吧~