Advertisement
AlexAvram

Untitled

Nov 17th, 2024
21
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.36 KB | None | 0 0
  1. //set 2-prob 2
  2. #include <iostream>
  3.  
  4. using namespace std;
  5. /*
  6. n=12
  7. 1 2 3 /4/
  8. s=6
  9. 12-(6+4)>=5
  10. */
  11. int main()
  12. {
  13. int n, s=0, x=1;
  14. cin>>n;
  15. if (n==0)
  16. {
  17. cout<<0;
  18. return 0;
  19. }
  20. while (n-(s+x)>=x+1)
  21. {
  22. cout<<x<<' ';
  23. s+=x;
  24. ++x;
  25. }
  26. if (s!=n)
  27. cout<<n-s;
  28.  
  29. return 0;
  30. }
  31.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement