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. HDU 1512 Monkey King ——左偏树

    [题目分析] 也是堆+并查集. 比起BZOJ 1455 来说,只是合并的方式麻烦了一点. WA了一天才看到是多组数据. 盲人OI (- ̄▽ ̄)- Best OI. 代码自带大常数,比启发式合并都慢 [ ...

  2. 向nginx发送reopen信号以重新打开日志文件

    先移动日志文件 mv /usr/local/openresty/nginx/logs/access.log /usr/local/openresty/nginx/logs/access.log.201 ...

  3. NOIp #2009

    http://files.cnblogs.com/files/radiumlrb/NOIP2009%E6%8F%90%E9%AB%98%E7%BB%84%E5%A4%8D%E8%B5%9B%E8%AF ...

  4. How To Handle a Loss of Confidence in Yourself

    Do you feel like you've lost confidence in yourself? Have you had strong self doubts? Perhaps you we ...

  5. ouath原理

    1.OAuth的简述 OAuth(Open Authorization,开放授权)是为用户资源的授权定义了一个安全.开放及简单的标准,第三方无需知道用户的账号及密码,就可获取到用户的授权信息,并且这是 ...

  6. php上传大文件时,服务器端php.ini文件中需要额外修改的选项

    几个修改点: 1.upload_max_filesize 上传的最大文件 2.post_max_size 上传的最大文件 3.max_execution_time 修改为0表示无超时,一直等待 4.m ...

  7. MySQL(无GUI) Windows安装和启动

    1.在官网http://dev.mysql.com/downloads/下载 MySQL Community Server 2.解压后是这个样子: 3.找到cmd,并且用管理员权限启动,必须!不然那没 ...

  8. Matlab中常用机器学习函数

    更多内容请参考http://cn.mathworks.com/help/stats/index.html?s_cid=doc_ftr. Naive Bayes(朴素贝叶斯) Factor = Naiv ...

  9. IDEA +maven+ ContextLoaderListener not find

    tomcat 启动失败:SEVERE: Context [] startup failed due to previous errors 查看pox.xml 有spring-web依赖 查看tomca ...

  10. CentOS 下部署 ASP.NET Core环境

    一.安装dotnet 1.下载运行环境 https://www.microsoft.com/net/download/linux 下载Runtime:https://go.microsoft.com/ ...