fork(1) download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define dbg(x) cout<<#x<<" : "<<x<<endl
  5. #define rep(i,a,b) for(int i=(a);i<=(b);i++)
  6. #define inf 1000000000000000000
  7. priority_queue<ll,vector<ll>,greater<int>> qp;
  8. priority_queue<ll> qr;
  9. #define maxn 100005
  10. #define mod 1000000007
  11. #define cnt_ones __builtin_popcount
  12. int main(){
  13. // freopen("input.txt","r",stdin);
  14. // freopen("output.txt","w",stdout);
  15. ll S;
  16. cin>>S;
  17. ll maax = (ll)sqrt(8*S+1);
  18. maax = (maax-1)/2;
  19. for(ll n=maax;n>=1;n--){
  20. ll tu = 2*S-n-n*n;
  21. ll mau = 2*(n+1);
  22. if(tu%mau==0){
  23. if(tu==0) cout<<n;
  24. else cout<<n+1;
  25. return 0;
  26. }
  27. }
  28. cout<<0;
  29. return 0;
  30. }
Success #stdin #stdout 0.03s 5564KB
stdin
Standard input is empty
stdout
13267744