B. Ciel and Flowers
2013-08-27 09:37
148 查看
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Fox Ciel has some flowers: r red flowers, g green
flowers and b blue flowers. She wants to use these flowers to make several bouquets. There are 4 types of bouquets:
To make a "red bouquet", it needs 3 red flowers.
To make a "green bouquet", it needs 3 green flowers.
To make a "blue bouquet", it needs 3 blue flowers.
To make a "mixing bouquet", it needs 1 red, 1 green and 1 blue flower.
Help Fox Ciel to find the maximal number of bouquets she can make.
Input
The first line contains three integers r, g and b (0 ≤ r, g, b ≤ 109)
— the number of red, green and blue flowers.
Output
Print the maximal number of bouquets Fox Ciel can make.
Sample test(s)
input
output
input
output
input
output
Note
In test case 1, we can make 1 red bouquet, 2 green bouquets and 3 blue bouquets.
In test case 2, we can make 1 red, 1 green, 1 blue and 1 mixing bouquet.
解题说明:此题是一个排列组合问题,给出每朵花需要的材料和一堆原材料,要求最多得到多少朵花。首先应该是求混合得到的花的数目,然后再求单一颜色花的数目。
#include <iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
int main()
{
int a,b,c,ans;
cin>>a>>b>>c;
ans=min(a,min(b,c));
a-=ans;
b-=ans;
c-=ans;
if(a%3+b%3+c%3 == 4 && ans)
{
ans++;
}
ans+=a/3+b/3+c/3;
cout<<ans<<endl;
return 0;
}
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output
Fox Ciel has some flowers: r red flowers, g green
flowers and b blue flowers. She wants to use these flowers to make several bouquets. There are 4 types of bouquets:
To make a "red bouquet", it needs 3 red flowers.
To make a "green bouquet", it needs 3 green flowers.
To make a "blue bouquet", it needs 3 blue flowers.
To make a "mixing bouquet", it needs 1 red, 1 green and 1 blue flower.
Help Fox Ciel to find the maximal number of bouquets she can make.
Input
The first line contains three integers r, g and b (0 ≤ r, g, b ≤ 109)
— the number of red, green and blue flowers.
Output
Print the maximal number of bouquets Fox Ciel can make.
Sample test(s)
input
3 6 9
output
6
input
4 4 4
output
4
input
0 0 0
output
0
Note
In test case 1, we can make 1 red bouquet, 2 green bouquets and 3 blue bouquets.
In test case 2, we can make 1 red, 1 green, 1 blue and 1 mixing bouquet.
解题说明:此题是一个排列组合问题,给出每朵花需要的材料和一堆原材料,要求最多得到多少朵花。首先应该是求混合得到的花的数目,然后再求单一颜色花的数目。
#include <iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<cstdlib>
using namespace std;
int main()
{
int a,b,c,ans;
cin>>a>>b>>c;
ans=min(a,min(b,c));
a-=ans;
b-=ans;
c-=ans;
if(a%3+b%3+c%3 == 4 && ans)
{
ans++;
}
ans+=a/3+b/3+c/3;
cout<<ans<<endl;
return 0;
}
相关文章推荐
- 想法题——Codeforces Round #190 (Div. 2)——B. Ciel and Flowers
- Codeforces Round #190 (Div. 2) B. Ciel and Flowers
- 322A - Ciel and Dancing 322B - Ciel and Flowers
- Codeforce 题目621C Wet Shark and Flowers(期望)
- Codeforces #341 div2 C.Wet Shark and Flowers(概率)
- hdu 4614 Vases and Flowers
- Codeforces Round #261 (Div. 2) B. Pashmak and Flowers (水题)
- Codeforces Round #261 (Div. 2) B. Pashmak and Flowers
- hdu 4614 Vases and Flowers(线段树+二分)
- Codeforces Round #381 (Div. 2) B. Alyona and flowers
- hdu-4614-Vases and Flowers-线段树
- HDU 4614 Vases and Flowers(线段树+二分)
- Codeforces #258 Div.2 E Devu and Flowers
- hdu 4614 Vases and Flowers (二分 线段树)
- B. Alyona and flowers
- HDU 4614 Vases and Flowers (线段树 + 二分)
- [CF 321D]Ciel and Flipboard解题报告
- hdu 4614 Vases and Flowers(线段树)
- Vases and Flowers HDU - 4614(线段树区间更新)
- hdu 4614 Vases and Flowers(线段树+二分)