标签:题目 inf include amp nbsp out bit tps turn
题目链接:
https://www.nowcoder.com/practice/9b59014cc1544aeeb4082f5f37ecfaea?tpId=122&&tqId=33725&rp=1&ru=/ta/exam-wangyi&qru=/ta/exam-wangyi/question-ranking
一个正整数n,表示贝壳的总数量,1<=n<=1000000000000000000。
一个正整数m,表示妞妞一次最少取的贝壳数量。
10
1
70
3
AC代码:
#include<bits/stdc++.h> using namespace std; #define ll long long int isOK(ll n,ll m) { ll a=0,b=0;//a->牛牛;b->妞妞;妞妞先手 while(n>0) { if(m>=n) { b+=n; n=0; } else { b+=m; n-=m; a+=n/10; n-=n/10; } } return b>=a; } int main() { ll n; cin>>n; ll l=1,r=n,ans=-1; while(l<=r) { ll mid=(l+r)>>1; if(isOK(n,mid)) { ans=mid; r=mid-1; } else l=mid+1; } cout<<ans<<endl; return 0; }
参考代码:
标签:题目 inf include amp nbsp out bit tps turn
原文地址:https://www.cnblogs.com/dragondragon/p/13390521.html