poj 1032
2017-01-22 11:05
183 查看
题目
ParliamentTime Limit: 1000MS | Memory Limit: 10000K | |
Total Submissions: 18695 | Accepted: 7934 |
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 CodeProblem: 1032 | User: PaladinDu | |
Memory: 164K | Time: 16MS | |
Language: C | Result: Accepted |
#include <stdio.h> /* * 求乘集最大的整数集合,数字不能重复,且和等于N。 * 很显然,数字数量越多越好,不要有1。数字相同的情况下靠的越紧越大 * 可以预期这个整数集 * 是一段连续的数,或是两段连续的数且中间只间隔一个数 * 这个里的N范围很小,可以打表,不过没什么意义。 */ #define __INT_BUF_LEN__ 100 int TMP[__INT_BUF_LEN__];//存从2开始,到n的和 void fInit() { int i ; TMP[1]=0; for(i=2;i<__INT_BUF_LEN__;++i) { TMP[i]=TMP[i-1]+i; } } int main() { int N; int i,j,dif; fInit(); scanf("%d",&N); for(i=3;i<__INT_BUF_LEN__;++i) { if(TMP[i]>N) { break; } } dif = TMP[i]-N; /* * 有两种中情况 * 如果dif=1 #因为我们总是不用1所以没法用1来填补差值 * 就是3到i-1加上i+1 * 如果是其他则是 * 2到dif-1加上dif+1到i (dif == 2 || def ==i )是去头去尾 */ switch(dif) { case 1: for(j=3;j<=i-1;++j) { printf("%d ",j); } printf("%d",i+1); break; default: for(j=2;j<=i;++j) { if(j!=dif) { printf("%d ",j); } } break; } return 0; }
相关文章推荐
- HDOJ 1032(POJ 1207) The 3n + 1 problem
- POJ 1032 Parliament 简单数论整数拆分
- poj1032 数论
- poj解题报告——1032
- POJ 1207 && HDU 1032 The 3n + 1 problem(水~)
- HDOJ 1032(POJ 1207) The 3n + 1 problem
- POJ 1032
- http://poj.org/problem?id=1032
- poj 1032 Parliament
- POJ 1032 / Northeastern Europe 1998 Parliament (贪心)
- poj 1032 Parliament 编程的小技巧
- poj1032 Parliament
- POJ 1032 最大乘积
- POJ 1265 Area(ZOJ 1032)(pick定理)
- 【简单题】POJ1032解题报告
- 1032. Find a Multiple poj 2356 Find a multiple
- POJ-1032-拆数字
- (Relax 水题1.2)POJ 1032 Parliament(将n分解成若干个互不相等的整数的和,并且是这些整数的乘积最大)
- POJ1032 Parliament【水题】
- POJ1032 Parliament