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最佳继承范型

    先回想下怎么给一个类设置属性:1.构造函数 内  通过this2.prototype中的属性两者的区别就是构造函数中的属性是每个实例私有的,而prototype中的属性是所有实例共有的(一般方法和静态 ...

  2. Codeforces525E Anya and Cubes(双向搜索)

    题目 Source http://codeforces.com/contest/525/problem/E Description Anya loves to fold and stick. Toda ...

  3. 【原】iOS学习之控制器的创建

    本次博客是一篇总结性质的博客,总结的是各种创建控制器的方式以及一些需要注意的操作. 1.通过storyboard创建控制器 正如我上一篇博客中所说,当 Main Interface 没有选定的时候,我 ...

  4. HDU5942 : Just a Math Problem

    \[\begin{eqnarray*}ans&=&\sum_{i=1}^ng(i)\\&=&\sum_{i=1}^n\sum_{d|i}\mu^2(d)\\&= ...

  5. Shader实例:边缘发光和描边

    效果图: 1.边缘发光 思路:用视方向和法线方向点乘,模型越边缘的地方,它的法线和视方向越接近90度.点乘越接近0 那么用 1-减去上面点乘的结果,来作为颜色分量,来反映边缘颜色强弱. Shader ...

  6. MySQL:索引工作原理

    索引查找:通过索引键找到索引的叶子节点,再通过叶子节点的标记快速找到表中对应的行数据,再返回指定的列 索引找查是通过索引键定先位到一块局部区域,再开始扫描匹配的数据的. 为什么需要索引(Why is ...

  7. Spring注入方式及注解配置

    一:基于xml的DI(Dependency Injection) 注入类型: 定义学生Student实体类和小汽车Car实体类:进行封装和生成ToString(),并自定义属性Car Student ...

  8. *HDU 1068 二分图

    Girls and Boys Time Limit: 20000/10000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  9. [IT新应用]家用NAS,自建“360云盘”

    360云盘也快要离开了.同事中有人开始尝试使用群晖NAS.西数的NAS来自建云了. [功能对比] [选择参数] [口碑评价]

  10. can't resolve symbol 'R' ...

    in android studio IDE: 解决: Tools -> Android -> Sync Project with Gradle Files