2022.Santa Claus and Candies

Time Limit: 1s Memory Limit: 256MB

Santa Claus has n candies, he dreams to give them as gifts to children.

What is the maximal number of children for whose he can give candies if Santa Claus want each kid should get distinct positive integer number of candies. Santa Class wants to give all n candies he has.

Input Format(From the terminal/stdin)

The only line contains positive integer number n (1 \le n \le 1000) - number of candies Santa Claus has.

Output Format(To the terminal/stdout)

Print to the first line integer number k - maximal number of kids which can get candies.

Print to the second line k distinct integer numbers: number of candies for each of k kid. The sum of k printed numbers should be exactly n.

If there are many solutions, print any of them.

Sample Input 1

Copy
5
 \n

Sample Output 1

Copy
2
2 3
 \n
 · \n

Sample Input 2

Copy
9
 \n

Sample Output 2

Copy
3
3 5 1
 \n
 · · \n

Sample Input 3

Copy
2
 \n

Sample Output 3

Copy
1
2 
 \n
 \n

Submit

请先 登录

© 2025 FAQs