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. 20165215 MySort的实现

    MySort的实现 要求 模拟实现Linux下Sort -t : -k 2的功能 要有伪代码,产品代码,测试代码(注意测试用例的设计) import java.util.*; public class ...

  2. ztree模糊搜索

      <!DOCTYPE html> <html lang="zh-CN"> <head> <meta http-equiv="X ...

  3. pytesseract使用的坑

    今天学了下python的OCR识别,其中遇到好多坑,下面就一一阐述是如何破解的,本人用的是Windows 64位,IDE是VS2017. pip版本过低. 首先安装pytesseract这个库,pip ...

  4. Keepalived原理与实战精讲--VRRP协议

    . 前言 VRRP(Virtual Router Redundancy Protocol)协议是用于实现路由器冗余的协议,最新协议在RFC3768中定义,原来的定义RFC2338被废除,新协议相对还简 ...

  5. vue_elementUI_ tree树形控件 获取选中的父节点ID

    el-tree 的 this.$refs.tree.getCheckedKeys() 只可以获取选中的id 无法获取选中的父节点ID想要获取选中父节点的id;需要如下操作1. 找到工程下的node_m ...

  6. Bitmap的秘密

    作者: 周海鹏  来源: infoQ  发布时间: 2015-02-13 11:26  阅读: 4999 次  推荐: 10   原文链接   [收藏] 之前已经参加过几次QCon峰会,不过今年QCo ...

  7. [C++ Primer Plus] 零散知识点(一)、输入函数(cin,cin.get,cin.getline等)+string头文件辨析

    本文几乎照搬http://www.cnblogs.com/luolizhi/p/5746775.html博客,只修改了一点点.不知道怎么转发过来,尴尬... 学C++的时候,这几个输入函数弄的有点迷糊 ...

  8. wepy开发小程序eslint报错error 'getApp' is not defined no-undef

    wepy开发小程序使用getApp().globalData保存全局数据很方便,但是会在控制台看到很多报错:“error 'getApp' is not defined no-undef”,这是esl ...

  9. FLEX外包团队:Flex例子DEMO源码

    代码如下: <?xml version="1.0" encoding="utf-8"?> <mx:Application xmlns:mx=& ...

  10. pytest文档13-allure2生成html报告(史上最详细)

    前言 allure是一个report框架,支持java的Junit/testng等框架,当然也可以支持python的pytest框架,也可以集成到Jenkins上展示高大上的报告界面. 环境准备 1. ...