Parliament
Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 19103   Accepted: 8101

Description

New convocation of The Fool Land's Parliament consists of N delegates. According to the present regulation delegates should be divided into disjoint groups of different sizes and every day each group has to send one delegate to the conciliatory committee. The composition of the conciliatory committee should be different each day. The Parliament works only while this can be accomplished. 
You are to write a program that will determine how many delegates should contain each group in order for Parliament to work as long as possible. 

Input

The input file contains a single integer N (5<=N<=1000 ).

Output

Write to the output file the sizes of groups that allow the Parliament to work for the maximal possible time. These sizes should be printed on a single line in ascending order and should be separated by spaces.

Sample Input

7

Sample Output

3 4

Source

 
 
看国家集训队2003论文集 邵烜程:《数学思想助你一臂之力》其中有详解;
 
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std; int n,tot,f[],ans,sum; int main(){
while(scanf("%d",&n)==){
tot=;
memset(f,,sizeof(f));
sum=n;
for(int i=;i<=n&&i<=sum;i++){
tot++;
f[tot]=i;
sum=sum-i;
}
if(sum==tot+) f[tot]++;
for(int i=tot;i>=tot-sum+;i--)
f[i]++;
for(int i=;i<tot;i++)
printf("%d ",f[i]);
if(tot) printf("%d",f[tot]);
printf("\n");
}
}

最新文章

  1. .net获取本机公网IP代码
  2. JS分页方法
  3. 开始学CI
  4. paip.c3p0 nullpointexcept 配置文件根路径读取bug 解决
  5. POJ 2449 Remmarguts&#39; Date --K短路
  6. python webdriver测试报告
  7. 使用jvisualvm和飞行记录器分析Java程序cpu占用率过高
  8. Kali Linux 安全渗透教程&amp;lt;第三更&amp;gt;1.2 安全渗透所需工具
  9. 【山东省选2008】郁闷的小J 平衡树Treap
  10. 【SqlServer系列】表达式(expression)
  11. 20190312_浅谈go&amp;java差异(一)
  12. Linux常用命令之-删除文件
  13. vue二次实战(一)
  14. python爬虫——对爬到的数据进行清洗的一些姿势(5)
  15. C现代编程
  16. MQ与webservice的区别,MQ的区别
  17. Inno Setup入门(四)——为程序创建桌面快捷方式
  18. 类的&quot;魔法&quot;方法
  19. java多线程实现主线程等待子线程执行完问题
  20. 使用Mysql慢查询日志对有效率问题的SQL进行监控

热门文章

  1. jq 动态添加.active 实现导航效果
  2. vue.js基础知识篇(4):过滤器、class与style的绑定2
  3. 现在开始学习WPF了,mongodb在整理一下
  4. 深入浅出数据结构C语言版(15)——优先队列(堆)
  5. if处理多分支结构
  6. ABP 框架学习-01篇
  7. Redis集群的相关概念
  8. javascript 代码放在head和body的区别
  9. group by 多字段分组
  10. nhibernate教程(4)--条件查询(Criteria Query)