Wannafly Winter Camp Day7 K 修炼

题意:

 

 ps:感觉这个翻译有问题,不是每天获得一个额外能力点,

  而是第一天获得1,第二天获得2,第三天获得3.....这样的可以任意分配的能力点

思路:对于这道题,我们直接暴力二分每一组数据即可

代码如下:

 1 #include<bits/stdc++.h>
 2 using namespace std;
 3 typedef long long ll;
 4 const int inf=0x3f3f3f3f3f3f;
 5 ll a,b;
 6 int check(ll mid,ll tmp1,ll tmp2)
 7 {
 8     ll val1=mid*a;
 9     ll val2=mid*b;
10     ll sum=mid*(mid+1)/2;
11     tmp1-=val1; if(tmp1<=0) tmp1=0;
12     tmp2-=val2; if(tmp2<=0) tmp2=0;
13     if(tmp1+tmp2>sum){
14         return 0;
15     }
16     else return 1;
17 }
18 int main()
19 {
20     scanf("%lld%lld",&a,&b);
21     ll n;
22     scanf("%lld",&n);
23     ll ans=inf;
24     for(ll i=1;i<=n;i++){
25         ll tmp1,tmp2;
26         scanf("%lld%lld",&tmp1,&tmp2);
27         ll tmpans;
28         ll L=0,R=inf;
29         while(L<=R){
30             ll mid=L+R>>1;
31             if(check(mid,tmp1,tmp2)){
32                 tmpans=mid;
33                 R=mid-1;
34             }
35             else L=mid+1;
36         }
37         ans=min(ans,tmpans);
38     }
39     printf("%lld\n",ans);
40     return 0;
41 }

 

posted @ 2020-09-03 19:44  古比  阅读(100)  评论(0编辑  收藏  举报