fork download
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. using namespace std;
  4. ll n,k,s=0;
  5. ll check(ll x)
  6. {
  7. ll p=n,t1=0,t2=0,res=n/2;
  8. while(p!=0)
  9. {
  10. if (p>=x)
  11. {
  12. t1+=x;
  13. p-=x;
  14. if (p>9) {t2+=p/10;p-=p/10;}
  15. }
  16. else {t1+=p;p-=p;}
  17. }
  18. if (t1>=res) return 1;
  19. else return 0;
  20. }
  21. ll tknp(ll l,ll r)
  22. {ll ans=10e8;
  23. while(l<=r)
  24. {
  25. ll g=(l+r)/2;
  26. if (check(g)!=0)
  27. {
  28. r=g-1;
  29. ans=g;
  30. }
  31. else l=g+1;
  32. }
  33. return ans;
  34. }
  35. int main()
  36. {
  37. cin>>n;
  38. s=tknp(0,10e18);
  39. cout<<s;
  40. return 0;
  41. }
  42.  
Success #stdin #stdout 0s 5284KB
stdin
Standard input is empty
stdout
Standard output is empty