fork download
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. typedef long long ll;
  4.  
  5. int main()
  6. {
  7. ll n, cnt=0;
  8. cin>>n;
  9. if(n%2 == 1)
  10. cnt++;
  11. ll d=n/2, f=0, sum=0;
  12. f=d;
  13. for(ll i=d; i>=1; i--)
  14. {
  15. sum+=i;
  16. if(sum == n)
  17. {
  18. cout<<i<<endl;
  19. cnt++;
  20. sum-=f;
  21. f--;
  22. }
  23. else if(sum > n)
  24. {
  25. sum-=f;
  26. f--;
  27. }
  28. }
  29. cout<<cnt<<endl;
  30. return 0;
  31. }
  32.  
  33.  
Success #stdin #stdout 0s 15240KB
stdin
19
stdout
1