B. Ciel and Flowers
来源:互联网 发布:淘宝金酷娃消防车视频 编辑:程序博客网 时间:2024/05/22 11:45
time limit per test
1 secondmemory limit per test
256 megabytesinput
standard inputoutput
standard outputFox 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;}
- B. Ciel and Flowers
- 322A - Ciel and Dancing 322B - Ciel and Flowers
- codeforces 322 B Ciel and Flowers
- Codeforces 322B Ciel and Flowers 规律
- CF 322B Ciel and Flowers 贪心水题
- 想法题——Codeforces Round #190 (Div. 2)——B. Ciel and Flowers
- codeforces B. Ciel and Duel
- B. Pashmak and Flowers
- B. Pashmak and Flowers
- B. Pashmak and Flowers
- B. Alyona and flowers
- Codeforces 321B Ciel and Duel KM
- 459B Pashmak and Flowers
- 【CODEFORCES】 B. Pashmak and Flowers
- #261B. Pashmak and Flowers
- CF190 DIV1 B Ciel and Duel 最大费用流
- Codeforces 459B Pashmak and Flowers(水题)
- CodeForces 459B. Pashmak and Flowers
- Linux内核中的Kconfig、Makefile、.config
- iOS开发之 Json解析的四种方法
- 深入研究 C++中的 STL Deque 容器
- CF197#DIV2:A-Helpful Maths
- 前端Web服务器+后台MySQL数据库+NFS服务
- B. Ciel and Flowers
- HDU 1142 A Walk Through the Forest
- 【rzxt】教你如何删除注册表的U盘使用记录
- android 蓝牙模块遇到的问题,关闭蓝牙以后下次不能正常连接
- Test
- CSS3之选择器
- VS2012:error LNK2026: 模块对于 SAFESEH 映像是不安全的
- dbca silent oraclle 11g R2 RAC 创建数据库试验
- WS_DELIVERY_UPDATE 修改数量、过账日期并发货过账