Poj 1032 Parliament

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

Northeastern Europe 1998

看国家集训队2003论文集 邵烜程:《数学思想助你一臂之力》其中有详解;

#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
using namespace std;

int n,tot,f[10008],ans,sum;

int main(){
    while(scanf("%d",&n)==1){
        tot=0;
        memset(f,0,sizeof(f));
        sum=n;
        for(int i=2;i<=n&&i<=sum;i++){
            tot++;
            f[tot]=i;
            sum=sum-i;
        }
        if(sum==tot+1) f[tot]++;
        for(int i=tot;i>=tot-sum+1;i--)
            f[i]++;
        for(int i=1;i<tot;i++)
            printf("%d ",f[i]);
        if(tot) printf("%d",f[tot]);
        printf("\n");
    }
}
时间: 2024-11-03 11:07:15

Poj 1032 Parliament的相关文章

poj 1032 Parliament 【思维题】

题目地址:http://poj.org/problem?id=1032 Parliament Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 17473   Accepted: 7371 Description New convocation of The Fool Land's Parliament consists of N delegates. According to the present regulation

poj 1032

这几天也是做了很多构造的题.有的难想,有的不难想. 题目要构造一个数拆分成一些数的和,使得这些数乘积最大.见代码. #include <iostream> using namespace std; int n, ans[1000], total; int main() { int i; bool first = true; //freopen("t.txt", "r", stdin); cin >> n; i = 2; total = 0;

1032 Parliament

描述愚人土地议会的新集会由N名代表组成. 根据现行规定,代表们应分为不同规模的不相交群体,每天每个小组必须派一名代表参加和解委员会. 和解委员会的组成应该每天都不同. 议会只有在完成这项工作的情况下才能运作.您将编写一个程序,确定每个组应包含多少代表,以便议会尽可能长时间地工作.输入输入文件包含单个整数N(5 <= N <= 1000).输出将输出文件写入允许议会在最长可能时间内工作的组的大小. 这些尺寸应按升序打印在一行上,并应以空格分隔.样例输入7样例输出3 4 /////////////

POJ百道水题列表

以下是poj百道水题,新手可以考虑从这里刷起 搜索1002 Fire Net1004 Anagrams by Stack1005 Jugs1008 Gnome Tetravex1091 Knight Moves1101 Gamblers1204 Additive equations 1221 Risk1230 Legendary Pokemon1249 Pushing Boxes 1364 Machine Schedule1368 BOAT1406 Jungle Roads1411 Annive

POJ题目推荐(转载)

POJ推荐50题1.标记“难”和“稍难”的题目可以看看,思考一下,不做要求,当然有能力的同学可以直接切掉.2.标记为A and B的题目是比较相似的题目,建议大家两个一起做,可以对比总结,且二者算作一个题目.3.列表中大约有70个题目.大家选做其中的50道,且每类题目有最低数量限制.4.这里不少题目在BUPT ACM FTP上面都有代码,请大家合理利用资源.5.50个题目要求每个题目都要写总结,养成良好的习惯.6.这个列表的目的在于让大家对各个方面的算法有个了解,也许要求有些苛刻,教条,请大家谅

ACM训练方案-POJ题目分类

ACM训练方案-POJ题目分类 博客分类: 算法 ACM online Judge 中国: 浙江大学(ZJU):http://acm.zju.edu.cn/ 北京大学(PKU):http://acm.pku.edu.cn/JudgeOnline/ 杭州电子科技大学(HDU):http://acm.hdu.edu.cn/ 中国科技大学(USTC):http://acm.ustc.edu.cn/ 北京航天航空大学(BUAA)http://acm.buaa.edu.cn/oj/index.php 南京

转载:poj题目分类(侵删)

转载:from: POJ:http://blog.csdn.net/qq_28236309/article/details/47818407 按照ac的代码长度分类(主要参考最短代码和自己写的代码) 短代码:0.01K–0.50K:中短代码:0.51K–1.00K:中等代码量:1.01K–2.00K:长代码:2.01K以上. 短:1147.1163.1922.2211.2215.2229.2232.2234.2242.2245.2262.2301.2309.2313.2334.2346.2348

POJ 2282-The Counting Problem(组合数学_区间计数)

The Counting Problem Time Limit:3000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 2282 Appoint description:  System Crawler  (2015-04-15) Description Given two integers a and b, we write the numbers between

POJ - 3186 Treats for the Cows (区间DP)

题目链接:http://poj.org/problem?id=3186 题意:给定一组序列,取n次,每次可以取序列最前面的数或最后面的数,第n次出来就乘n,然后求和的最大值. 题解:用dp[i][j]表示i~j区间和的最大值,然后根据这个状态可以从删前和删后转移过来,推出状态转移方程: dp[i][j]=max(dp[i+1][j]+value[i]*k,dp[i][j-1]+value[j]*k) 1 #include <iostream> 2 #include <algorithm&