Codeforces Round #107 (Div. 2)---A. Soft Drinking
This winter is so cold in Nvodsk! A group of n friends decided to buy k bottles of a soft drink called "Take-It-Light" to warm up a bit. Each bottle has l milliliters of the drink. Also they bought c limes and cut each of them into d slices. After that they found p grams of salt.
To make a toast, each friend needs nl milliliters of the drink, a slice of lime and np grams of salt. The friends want to make as many toasts as they can, provided they all drink the same amount. How many toasts can each friend make?
The first and only line contains positive integers n, k, l, c, d, p, nl, np, not exceeding 1000 and no less than 1. The numbers are separated by exactly one space.
Print a single integer — the number of toasts each friend can make.
3 4 5 10 8 100 3 1
2
5 100 10 1 19 90 4 3
3
10 1000 1000 25 23 1 50 1
0
A comment to the first sample:
Overall the friends have 4 * 5 = 20 milliliters of the drink, it is enough to make 20 / 3 = 6 toasts. The limes are enough for 10 * 8 = 80toasts and the salt is enough for 100 / 1 = 100 toasts. However, there are 3 friends in the group, so the answer is min(6, 80, 100) / 3 = 2.
解题思路:贪心。只是是小学数学题。。
。算出三种成分的最大值,取当中的最小值就可以。
AC代码:
#include <iostream> #include <cstring> #include <cstdio> using namespace std; int main(){ // freopen("in.txt", "r", stdin); int n,k,l,c,d,p,nl,np; while(cin>>n>>k>>l>>c>>d>>p>>nl>>np){ int a = (k * l) / nl; int aa = p / np; int aaa = c * d; int ans = min(a, min(aa, aaa)) / n; cout<<ans<<endl; } }
版权声明:本文博客原创文章,博客,未经同意,不得转载。