北大poj- 1032
Parliament
| Time Limit: 1000MS | Memory Limit: 10000K | |
| Total Submissions: 18707 | Accepted: 7941 |
Description
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
Output
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
#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的更多相关文章
- 北大POJ题库使用指南
原文地址:北大POJ题库使用指南 北大ACM题分类主流算法: 1.搜索 //回溯 2.DP(动态规划)//记忆化搜索 3.贪心 4.图论 //最短路径.最小生成树.网络流 5.数论 //组合数学(排列 ...
- poj 1032 Parliament 【思维题】
题目地址:http://poj.org/problem?id=1032 Parliament Time Limit: 1000MS Memory Limit: 10000K Total Submi ...
- POJ 1032问题描述
Description New convocation of The Fool Land's Parliament consists of N delegates. According to the ...
- Poj 1032 分类: Translation Mode 2014-04-04 09:09 111人阅读 评论(0) 收藏
Parliament Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 16521 Accepted: 6975 Descr ...
- (Relax 水题1.2)POJ 1032 Parliament(将n分解成若干个互不相等的整数的和,并且是这些整数的乘积最大)
题意:给出一个数n,将其拆分为若干个互不相等的数字的和,要求这些数字的乘积最大. 分析:我们可以发现任何一个数字,只要能拆分成两个大于1的数字之和,那么这两个数字的乘积一定大于等于原数.也就是说,对于 ...
- 【贪心】 poj 1032 和为n的若干数最大乘积
给出n,把n分解为若干不相同数之和,使之乘积最大.贪心,Discuss里面的思路:把n分解为从2开始的连续整数,如果有多,则从高位开始依次加1.如26,我们得到2+3+4+5+6,此时还剩余6(26- ...
- Poj 1032 Parliament
Parliament Time Limit: 1000MS Memory Limit: 10000K Total Submissions: 19103 Accepted: 8101 Descr ...
- POJ 1032
#include<iostream> using namespace std; int main() { int n; int num; ; int i,j; cin>>num ...
- 【Java】深深跪了,OJ题目Java与C运行效率对比(附带清华北大OJ内存计算的对比)
看了园友的评论之后,我也好奇清橙OJ是怎么计算内存占用的.重新测试的情况附在原文后边. -------------------------------------- 这是切割线 ----------- ...
- POJ 1861 Network (Kruskal算法+输出的最小生成树里最长的边==最后加入生成树的边权 *【模板】)
Network Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 14021 Accepted: 5484 Specia ...
随机推荐
- qemu 对虚机的地址空间管理
转载:http://huchh.com/2015/06/22/qemu-%E5%AF%B9%E8%99%9A%E6%9C%BA%E7%9A%84%E7%BA%BF%E6%80%A7%E5%9C%B0% ...
- Poj2386 Lake Counting (DFS)
Lake Counting Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 49414 Accepted: 24273 D ...
- django+nginx+python3 生产环境部署
一.安装python基础环境 1.安装各类基础模块 yum install gcc-c++ wget openssl-devel bzip2-devel expat-devel gdbm-devel ...
- Spring笔记 #02# 利用切面和注解校验方法参数
例子还是之前的例子.仍然是对mage进行法术攻击时的咒语进行校验,不过略微提高了扩展性. 应用示例 1.在.properties文件中定义参数格式(正则): sp1=^\\D*hello\\D*$ s ...
- flutter的webview案例
flutter 加载webview 安装插件 flutter_webview_plugin: ^0.2.1 从listview点击item跳转页面加载详情页案例 import 'dart:async ...
- Shell data、timedatectl
data系统时间管理命令 命令date +%F xxxx—xx--xx #查看当前日期. 命令date +%T xx:xx:xx #查看当前时间. 命令date +%y xx #年2位 命令date ...
- [C++ Primer Plus] 第7章、函数(二)课后习题
一.复习题 6.为什么不对基本数据类型的函数参数使用const? 8.编写一个函数,将字符串中所有c1替换成c2,并返回替换次数. #include<iostream> using nam ...
- SSM-网站后台管理系统制作(1)
好久没写博客了,忙于考试和项目答辩,今天整理一下想弄的SSM:本人想做的是博客管理平台,和博客园,CSDN,stackoverflow这些类似. 老师先让做的是后台管理系统,先给出来吧. (讲解内容: ...
- JS设计模式(4)迭代器模式
什么是迭代器模式? 定义:提供一种方法顺序访问一个聚合对象中各个元素, 而又无须暴露该对象的内部表示. 主要解决:不同的方式来遍历整个整合对象. 何时使用:遍历一个聚合对象. 如何解决:把在元素之间游 ...
- ShareSVN授权的代码示例
var targetUrl = "your svn url path"; var path = "Temp"; System.Collections.Objec ...