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