Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //set 2-prob 2
- #include <iostream>
- using namespace std;
- /*
- n=12
- 1 2 3 /4/
- s=6
- 12-(6+4)>=5
- */
- int main()
- {
- int n, s=0, x=1;
- cin>>n;
- if (n==0)
- {
- cout<<0;
- return 0;
- }
- while (n-(s+x)>=x+1)
- {
- cout<<x<<' ';
- s+=x;
- ++x;
- }
- if (s!=n)
- cout<<n-s;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement