codeforces 785D
2017-03-16 21:12
288 查看
http://codeforces.com/problemset/problem/785/D
#include <bits/stdc++.h> #define maxs 20202 #define mme(i,j) memset(i,j,sizeof(i)) using namespace std; char s[maxs]; #define ll long long int main() { ll n,m; while(cin>>n>>m) { if(n<=m) { cout<<n<<endl; continue; } n-=(m+1); if(n<=0) { cout<<m+1<<endl; continue; } ll l=0,r=2e10+3; ll cost,mid,t=0,ans=m; while( l<=r ) { mid = ( l+r )>>1; cost = ( mid+2 )*( mid-1 )/2; if(cost>=n) { t=mid; r=mid-1; } else l=mid+1; } ans+=t; cout<<ans<<endl; } return 0; }
相关文章推荐
- Codeforces-785D-Anton and School - 2(组合数学,范德蒙恒等式)
- Codeforces 785D 数学
- codeforces 785d[补]
- 【codeforces 785D】Anton and School - 2
- CodeForces - 785D
- [刷题]Codeforces 785D - Anton and School - 2
- Codeforces 785D 范德蒙恒等式的变形
- Codeforces 785D - Anton and School - 2(范德蒙恒等式+逆元)
- Codeforces 512B Fox And Jumping dp+gcd
- codeforces 589d(相遇问题)
- codeforces 839D (推公式+容斥原理/莫比乌斯函数)
- codeforces 509F Progress Monitoring (区间dp)
- 【动态规划】Codeforces 706C Hard problem
- CodeForces - 53D Physical Education
- codeforces 478D Red-Green Towers (dp)
- CodeForces 705B (训练水题)
- Table CodeForces - 232B(144 div1 B) (dp+快速幂)
- Codeforces-507-C(c++)
- CodeForces 327C
- Codeforces 839A Arya and Bran