753 A. Santa Claus and Candies
来源:互联网 发布:win7搜不到网络打印机 编辑:程序博客网 时间:2024/06/05 04:33
A. Santa Claus and Candies
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
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
The only line contains positive integer number n (1 ≤ n ≤ 1000) — number of candies Santa Claus has.
Output
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.
Examples
Input
5
Output
2
2 3
Input
9
Output
3
3 5 1
Input
2
Output
1
2
#include<stdio.h>#define maxn 1000int a[maxn];void init();int main(){ init(); int n,i; while(~scanf("%d",&n)) { if(n==1||n==2) { printf("%d\n",1); printf("%d\n",n); continue; } printf("%d\n",a[n]); int sum=0; for(i=1;i<a[n];i++) { sum+=i; printf("%d ",i); } printf("%d\n",n-sum); } return 0;}void init(){ int s=1; int i,j; for(i=1;i<=1000;i+=s) { for(j=i;j<i+s+1;j++) a[j]=s; s++; }///n分成若干个不相等的数}
- 753 A. Santa Claus and Candies
- cf 753A Santa Claus and Candies
- Codeforces753A Santa Claus and Candies
- 748A. Santa Claus and a Place in a Class
- A. Santa Claus and a Place in a Class
- A. Santa Claus and a Place in a Class
- CF # 389 Santa Claus and a Place in a Class
- CF # 389 Santa Claus and a Place in a Class
- 【codeforces 752D】Santa Claus and a Palindrome
- Codeforces748D-Santa Claus and a Palindrome(贪心,构造)
- Codeforces Round #389 (Div. 2):Santa Claus and a Palindrome
- Codeforces 752D Santa Claus and a Palindrome map应用
- Codeforces 748 D Santa Claus and a Palindrome
- codeforces748c-Santa Claus and Robot
- 【codeforces 752A】Santa Claus and a Place in a Class
- 【Codeforces Round #389】Codeforces 752A Santa Claus and a Place in a Class
- Codeforces Round #389 (Div. 2)A. Santa Claus and a Place in a Class(水题)
- 748 A. Santa Claus and a Place in a Class codeforces
- 【凡凡说项目】挑一件事情坚持下去
- 学习小记 - Python爬虫 (3) 利用Python爬取wanimal所有图片
- android sdk 更新可用的
- Android Studio 的项目怎么导入Eclipse
- Linux内核的list_head民用改造
- 753 A. Santa Claus and Candies
- eclipse 插件 Spring Tools 一直占用jar,导致无法删除jar包
- gdb工作原理和内核实现
- BaseAdapter中怎么使用Application全局变量
- 2016秋招笔试面试题一:Java及基础部分
- phpstorm 激活
- 请问Android中怎么在一个线性布局里面添加多个图表控件
- 国内外知名IT科技博客(强烈推荐)
- PSAM卡之常用APDU指令错误码