csuoj 1391: Boiling Vegetables
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1391
1391: Boiling Vegetables
Time Limit: 1 Sec Memory Limit: 128 MB
Submit: 27 Solved: 14
[Submit][Status][Web Board]
Description

Input

Output

Sample Input
0.99 3
2000 3000 4000
Sample Output
6
HINT

Source
分析:
暴力枚举。
AC代码;
#include <iostream>
#include <cstring>
#include <cstdio>
#include <algorithm>
#include <cmath> using namespace std; double vagetable[],limit;
int n; int main()
{
cin>>limit>>n;
for(int i=;i<n;i++) cin>>vagetable[i]; if(n==)
{
cout<<<<endl;
return ;
} sort(vagetable,vagetable+n,less<double>()); int ans=; for(int i=;i<n;i++)
{
for(int c=;c<ans;c++)
{
double maxsize=vagetable[i]/(c+);
double minsize=maxsize*limit; int temp=c;
bool flag=true; for(int j=;j<n;j++)
{
if(i==j) continue; int c1=(int)ceil(vagetable[j]/maxsize)-; if(vagetable[j]/(c1+) < minsize)
{
flag=false; break;
}
temp+=c1;
if(temp>=ans)
{
flag=false; break;
}
}
if(flag)
{
ans=min(ans,temp);
}
}
}
cout<<ans<<endl;
return ;
}
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<iostream>
using namespace std;
double a[];
int main()
{
double T,maxx,minn;
int n,i,j,k,PP,sum,flag;
while(~scanf("%lf%d",&T,&n))
{
PP=;
for(i=;i<n;i++)
scanf("%lf",&a[i]);
for(i=;i<n;i++)
for(j=;j<=;j++)
{
sum=j;flag=;
maxx=a[i]*1.0/(j+);
minn=maxx*T;
for(k=;k<n && flag==;k++)
{
if(k==i)
continue;
int t1=(int)((a[k]-)/maxx);
double t2=a[k]*1.0/(t1+);
if(t2<minn)
{flag=;break;}
sum+=t1;
if(sum>PP)
{flag=;break;} }
if(flag==)
PP=min(PP,sum);
}
printf("%d\n",PP);
}
return ;
}
csuoj 1391: Boiling Vegetables的更多相关文章
- 2014 UESTC 暑前集训队内赛(1) 解题报告
A.Planting Trees 排序+模拟 常识问题,将耗时排一个序,时间长的先种,每次判断更新最后一天的时间. 代码: #include <iostream> #include < ...
- BZOJ 1391: [Ceoi2008]order [最小割]
1391: [Ceoi2008]order Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 1509 Solved: 460[Submit][Statu ...
- hihoCoder 1391 Countries【预处理+排序+优先队列】2016北京网络赛
题目:http://hihocoder.com/problemset/problem/1391 题目大意: A和B两个国家互射导弹,每个国家都有一个防御系统,在防御系统开启的时间内可以将到达本国的导弹 ...
- csuoj 1511: 残缺的棋盘
http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1511 1511: 残缺的棋盘 时间限制: 1 Sec 内存限制: 128 MB 题目描述 输入 ...
- 离线树状数组 hihocoder 1391 Countries
官方题解: // 离线树状数组 hihocoder 1391 Countries #include <iostream> #include <cstdio> #include ...
- 【BZOJ】【1391】【CEOI2008】order
网络流/最小割 暴力建图就好了……S->i 容量为收益,i->j+n 容量为租金,j+n->T容量为购买所花的钱. 如果亏钱的话那么割掉的就是收益,表示不赚钱. 如果租金大于购买所花 ...
- csuoj 1354: Distinct Subsequences
这个题是计算不同子序列的和: spoj上的那个同名的题是计算不同子序列的个数: 其实都差不多: 计算不同子序列的个数使用dp的思想: 从头往后扫一遍 如果当前的元素在以前没有出现过,那么dp[i]=d ...
- Bzoj 1391: [Ceoi2008]order 网络流,最大权闭合图
1391: [Ceoi2008]order Time Limit: 10 Sec Memory Limit: 64 MBSubmit: 1105 Solved: 331[Submit][Statu ...
- hihoCoder 1391 Countries 【预处理+排序+堆】 (ACM-ICPC国际大学生程序设计竞赛北京赛区(2016)网络赛)
#1391 : Countries 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 There are two antagonistic countries, countr ...
随机推荐
- 2016 Multi-University Training Contest 1 C.Game
Game Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submis ...
- Linux文件系统扩容步骤
1 扩容前检查 cat /etc/fstab df -h 在扩容之前请确认VG的Free大小,以及文件和文件系统是否达到系统限制 2 系统识别硬盘 #echo "- - -" &g ...
- SPX Instant Screen Capture
Today I will recommend a NICE screen capture tool, which name is SPA Instant Screen Capture. http:// ...
- css样式表分类、选择器分类、css基础样式
1 . 样式表 Cascading Style Sheet css优势: 内容与表现分离 网页的表现统一,容易修改 丰富的样式,使网页布局更加灵活 减少网页代码量,增加网页的浏览速度,节省 ...
- bigint数据类型
尽管int依然是SQL Server 2000中最主要的整数数据类型,但是SQL Server 2000还是新增加了整数数据类型bigint,它应用于整数超过int数据范围的场合. int数据类型所表 ...
- [转]Flash Player、AIR、Flex SDK 大全
平时不断看到有朋友在各种论坛.空间.知道.群里求 Flash 平台各种版本的运行时(Flash Player)和SDK(Flex.AIR).今天就看到不下10次!所以决定把 Macromedia.Ad ...
- Python实战2( 接上):扫描多余中文
还是接上一篇,扫描多余中文,支持自定义忽略字段 源代码,详看 http://pan.baidu.com/s/1ntC78Zv ScanChinese.zip
- css3新特性
1.css3选择器 我们所定义的 CSS 属性之所以能应用到相应的节点上,就是因为 CSS 选择器模式.参考下述代码: Body > .mainTabContainer div > s ...
- iOS 常用的向上,向下取整, 四舍五入函数
向上取整:ceil(x),返回不小于x的最小整数; 向下取整:floor(x),返回不大于x的最大整数; 四舍五入:round(x) 截尾取整函数:trunc(x)
- centos关闭防火墙
Centos7 关闭防火墙 CentOS 7.0默认使用的是firewall作为防火墙,使用iptables必须重新设置一下 1.直接关闭防火墙 systemctl stop firewalld.se ...