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的更多相关文章

  1. 2014 UESTC 暑前集训队内赛(1) 解题报告

    A.Planting Trees 排序+模拟 常识问题,将耗时排一个序,时间长的先种,每次判断更新最后一天的时间. 代码: #include <iostream> #include < ...

  2. BZOJ 1391: [Ceoi2008]order [最小割]

    1391: [Ceoi2008]order Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 1509  Solved: 460[Submit][Statu ...

  3. hihoCoder 1391 Countries【预处理+排序+优先队列】2016北京网络赛

    题目:http://hihocoder.com/problemset/problem/1391 题目大意: A和B两个国家互射导弹,每个国家都有一个防御系统,在防御系统开启的时间内可以将到达本国的导弹 ...

  4. csuoj 1511: 残缺的棋盘

    http://acm.csu.edu.cn/OnlineJudge/problem.php?id=1511 1511: 残缺的棋盘 时间限制: 1 Sec  内存限制: 128 MB 题目描述 输入 ...

  5. 离线树状数组 hihocoder 1391 Countries

    官方题解: // 离线树状数组 hihocoder 1391 Countries #include <iostream> #include <cstdio> #include ...

  6. 【BZOJ】【1391】【CEOI2008】order

    网络流/最小割 暴力建图就好了……S->i 容量为收益,i->j+n 容量为租金,j+n->T容量为购买所花的钱. 如果亏钱的话那么割掉的就是收益,表示不赚钱. 如果租金大于购买所花 ...

  7. csuoj 1354: Distinct Subsequences

    这个题是计算不同子序列的和: spoj上的那个同名的题是计算不同子序列的个数: 其实都差不多: 计算不同子序列的个数使用dp的思想: 从头往后扫一遍 如果当前的元素在以前没有出现过,那么dp[i]=d ...

  8. Bzoj 1391: [Ceoi2008]order 网络流,最大权闭合图

    1391: [Ceoi2008]order Time Limit: 10 Sec  Memory Limit: 64 MBSubmit: 1105  Solved: 331[Submit][Statu ...

  9. hihoCoder 1391 Countries 【预处理+排序+堆】 (ACM-ICPC国际大学生程序设计竞赛北京赛区(2016)网络赛)

    #1391 : Countries 时间限制:1000ms 单点时限:1000ms 内存限制:256MB 描述 There are two antagonistic countries, countr ...

随机推荐

  1. JS冒泡排序(数组)

    冒泡排序是把数组相邻的两个值进行比较,然后根据条件执行相应的命令 var arr = [0,4,8,5,2,7,1,3,6,9]; for(var s = 0;s<arr.length;s++) ...

  2. 清华学堂 列车调度(Train)

    列车调度(Train) Description Figure 1 shows the structure of a station for train dispatching. Figure 1 In ...

  3. Unity Standard Assets 简介之 CrossPlatformInput

    这篇介绍跨平台输入工具包CrossPlatformInput,主要包括 Prefabs 和 Scripts 两个文件夹: 由于该包中的脚本联系比较紧密,都是配合着去实现特定的功能,没有太大的独立可重用 ...

  4. Windows平台下为Python添加MongoDB支持PyMongo

    到Python官网下载pymongo-2.6.3.win-amd64-py2.7.exe 安装pymongo-2.6.3.win-amd64-py2.7.exe 参照官方的用例进行测试 打开命令提示符 ...

  5. JSHint Options 翻译

    Enforcing options When set to true, these options will make JSHint produce more warnings about your ...

  6. Python中输出格式化的字符串

    在Python中,采用的格式化方式和C语言是一致的,用%实现,举例如下: >>> 'Hello, %s' % 'world' 'Hello, world' >>> ...

  7. jquery mobile页面跳转缓存问题解决

    最近,我的一个写后端的同事因为缺前端自己做起了前端的活儿,因为对前端的不熟悉,找寻了一些现成框架想轻松了事,做一个web app他选了jquery mobile,开发效率确实高,但是这个框架的一些坑也 ...

  8. NSNotification\KVO\block\delegate的区别和用法

    在开发ios应用的时候,我们会经常遇到一个常见的问题:在不过分耦合的前提下,controllers间怎么进行通信.在IOS应用不断的出现三种模式来实现这种通信: 1.委托delegation: 2.通 ...

  9. oracle优化

    sql语句 优化方式: 1select 语句中避免用"*" oracle在解析时,会将“*”依次转换成所有的列名(数据字典完成)耗时 2尽量多用commit语句 及时提交,释放资源 ...

  10. MyBatis实现关联表查询

    一.一对一关联 1.1.提出需求 根据班级id查询班级信息(带老师的信息) 1.2.创建表和数据 创建一张教师表和班级表,这里我们假设一个老师只负责教一个班,那么老师和班级之间的关系就是一种一对一的关 ...