SHARE
    TWEET
    AlexAvram

    Untitled

    Nov 17th, 2024
    75
    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. using namespace std;
    4. /*
    5. n=12
    6. 1 2 3 /4/
    7. s=6
    8. 12-(6+4)>=5
    9. */
    10. int main()
    11. {
    12. int n, s=0, x=1;
    13. cin>>n;
    14. if (n==0)
    15. {
    16. cout<<0;
    17. return 0;
    18. }
    19. while (n-(s+x)>=x+1)
    20. {
    21. cout<<x<<' ';
    22. s+=x;
    23. ++x;
    24. }
    25. if (s!=n)
    26. cout<<n-s;
    27. return 0;
    28. }
    Advertisement
    Add Comment
    Please, Sign In to add comment
    Public Pastes
    We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
    Not a member of Pastebin yet?
    Sign Up, it unlocks many cool features!

    AltStyle によって変換されたページ (->オリジナル) /