fork download
  1. #include<bits/stdc++.h>
  2. #define FOR(i,a,b) for(long long int i=(a);i<=(b);++i)
  3. #define NFOR(i,a,b) for(long long int i=(a);i>=(b);--i)
  4. #define pb push_back
  5. #define ll long long
  6. #define F first
  7. #define S second
  8. #define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
  9. #define MOD 1000000007
  10. using namespace std;
  11. //ll prime[10000007];
  12. //vector<ll>stprime;
  13. //ll fastpow(ll base, ll exp) {ll res=1;while(exp>0) {if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return res%MOD;}
  14. //void sieve(){memset(prime,1,sizeof(prime));prime[0]=0;prime[1]=0;for(ll i=2;i*i<=10000000;++i){if(prime[i]){for(ll j=i*i;j<=10000000;j+=i)prime[j]=0;}}FOR(i,1,1000000){if(prime[i])stprime.pb(i);}}
  15. //bool comp(const ll &a,const ll &b){if(a>b)return true;else return false;}
  16. //**********************************************************************************************************************************************//
  17. int main()
  18. {
  19.  
  20. fast;
  21. ll t,n,h,q,x,y,w,m;
  22. cin>>n>>m;
  23. ll temp=m;
  24. if(m>=n)
  25. {cout<<n<<endl;return 0;}
  26. m=n-m;
  27. ll him=pow(1+8*m,0.5);
  28. if(him*him!=1+8*m)
  29. him++;
  30. him-=1;
  31. ll temp1=him;
  32. him/=2;
  33. if(temp1%2!=0)him++;
  34. //cout<<him<<endl;
  35. ll ans=temp+him;
  36. cout<<ans<<endl;
  37.  
  38.  
  39.  
  40.  
  41.  
  42.  
  43.  
  44.  
  45.  
  46. return 0;
  47. }
Success #stdin #stdout 0s 16064KB
stdin
999999998765257152 10
stdout
1414213572