Parliament

Time Limit: 1000MS   Memory Limit: 10000K
Total Submissions: 18707   Accepted: 7941

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

 
分析:
题目的意思是,将一个数字拆分成互不相同的数,使它们的积最大。
 
解题:
如果不考虑条件“互不相同的”,那么最终结果肯定是2\3的组合(4拆2+2效果一样),比如10=5+5=2+3+2+3。
将“互不相同”纳入考虑范围,那么,这个组合必然是从2开始的,尽可能小的,一组数列。
那么可以,从2+3+4+...加到一个不大于N的值,再将剩余的值从大到小加回去。比如,26=2+3+4+5+6....6,再将6从大到小依次加回去,就得到答案3+4+5+6+8
 
 #include <stdio.h>

 int main(void)
{
int ans[] = {};
int all = ;
int sum = ;
int end = ;
int num = ;
int j = ;
int remaind = ;
scanf("%d",&all); while()
{
if(sum+end <= all)
{
sum = sum+end;
ans[num] = end;
num++;
end++;
}
else
{
remaind = all - sum;
break;
}
} j = num - ;
while(remaind > )
{
if(j<) j=num-;
ans[j]++;
j--;
remaind--;
} for(j=; j<num; j++)
{
printf("%d ", ans[j]);
} return ;
}

北大poj- 1032的更多相关文章

  1. 北大POJ题库使用指南

    原文地址:北大POJ题库使用指南 北大ACM题分类主流算法: 1.搜索 //回溯 2.DP(动态规划)//记忆化搜索 3.贪心 4.图论 //最短路径.最小生成树.网络流 5.数论 //组合数学(排列 ...

  2. poj 1032 Parliament 【思维题】

    题目地址:http://poj.org/problem?id=1032 Parliament Time Limit: 1000MS   Memory Limit: 10000K Total Submi ...

  3. POJ 1032问题描述

    Description New convocation of The Fool Land's Parliament consists of N delegates. According to the ...

  4. Poj 1032 分类: Translation Mode 2014-04-04 09:09 111人阅读 评论(0) 收藏

    Parliament Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 16521   Accepted: 6975 Descr ...

  5. (Relax 水题1.2)POJ 1032 Parliament(将n分解成若干个互不相等的整数的和,并且是这些整数的乘积最大)

    题意:给出一个数n,将其拆分为若干个互不相等的数字的和,要求这些数字的乘积最大. 分析:我们可以发现任何一个数字,只要能拆分成两个大于1的数字之和,那么这两个数字的乘积一定大于等于原数.也就是说,对于 ...

  6. 【贪心】 poj 1032 和为n的若干数最大乘积

    给出n,把n分解为若干不相同数之和,使之乘积最大.贪心,Discuss里面的思路:把n分解为从2开始的连续整数,如果有多,则从高位开始依次加1.如26,我们得到2+3+4+5+6,此时还剩余6(26- ...

  7. Poj 1032 Parliament

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

  8. POJ 1032

    #include<iostream> using namespace std; int main() { int n; int num; ; int i,j; cin>>num ...

  9. 【Java】深深跪了,OJ题目Java与C运行效率对比(附带清华北大OJ内存计算的对比)

    看了园友的评论之后,我也好奇清橙OJ是怎么计算内存占用的.重新测试的情况附在原文后边. -------------------------------------- 这是切割线 ----------- ...

  10. POJ 1861 Network (Kruskal算法+输出的最小生成树里最长的边==最后加入生成树的边权 *【模板】)

    Network Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 14021   Accepted: 5484   Specia ...

随机推荐

  1. Tomcat日志文件catalina.out文件过大问题

    随着项目的运行,Tomcat的日志文件catalina.out的大小日益增大,现在都有好几个GB了.如果我们不做任何处理,catalina.out的文件大小将会持续增加,直到把我们的系统硬盘空间给撑爆 ...

  2. flutter 常用插件

    audio_recorder: any #录音.播放 flutter_sound: ^1.1.5#录音 dropdown_menu: ^1.1.0#下拉菜单 simple_permissions:#权 ...

  3. 配置firewalld防火墙

    题:请按下列要求在 system1 和 system2 上设定防火墙系统: 允许 group8.example.com 域的客户对 system1 和 system2 进行 ssh 访问. 禁止 my ...

  4. saltstack 安装

    centos 6.5 saltstack 2015.5.10 (Lithium) tips:上个版本2015.5.3或者5.5有个bug,Python调用salt的unzip模块报错: 安装 在配置了 ...

  5. 【mysql】group_concat函数substring_index函数

    1.group_concat函数:用于将多个字符串连接成一个字符串 用法规则: SELECT GROUP_CONCAT(拼接的字段) from tableName; 使用:查询basic_projec ...

  6. scp传输文件,自动填充密码

    一个偷懒的小shell, #!/usr/bin/expect #******************************************************************** ...

  7. redux-thunk的理解

    问题:1.redux-thunk要解决什么问题? 要解决异步请求问题,Action发出以后,Reducer立即算出State,这叫做同步:Action发出以后,过一段时间再执行 Reducer,这就叫 ...

  8. 编码原则 之 Persistence Ignorance

    原文 The principle of Persistence Ignorance (PI) holds that classes modeling the business domain in a ...

  9. SQLyog 字体设置

    新公司连接数据库的工具是SQLyog,我以前使用的一直是Navicat,抱着多学个工具也不亏的想法我也安装了试下,但是SQLyog那紧凑的字体对于近视200度的我来说看着着实难受,在询问了公司前辈之后 ...

  10. springboot使用@Schednled 注解实现定时任务

    part 1: @Component public class Scheduled { SimpleDateFormat dateFormat = new SimpleDateFormat(" ...