HDU 2277 Change the ball(找规律)
来源:互联网 发布:虚幻4编程语言 编辑:程序博客网 时间:2024/05/02 16:49
Change the ball
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 643 Accepted Submission(s): 231
Problem Description
Garfield has three piles of balls, each pile has unique color of following: yellow, blue, and red. Now we also know Garfield has Y yellow balls, B blue balls, and R red balls. But Garfield just wants to change all the balls to one color. When he puts two balls of different color togather, the balls then change their colors automatically into the rest color. For instance, when Garfield puts a red one and a yellow one togather, the two balls immediately owns blue color, the same to other situations. But the rule doesn’t work when the two balls have the same color.
Garfield is not able to estimate the minimal steps to achieve the aim. Can you tell him?
Garfield is not able to estimate the minimal steps to achieve the aim. Can you tell him?
Input
For each line, there are three intergers Y, B, R(1<=Y,B,R<=1000),indicate the number refered above.
Output
For each case, tell Garfield the minimal steps to complete the assignment. If not, output the symbol “):”.
Sample Input
1 2 31 2 2
Sample Output
):2
Source
HDU 8th Programming Contest Site(1)
Recommend
lcy | We have carefully selected several similar problems for you: 2273 2276 2274 2279 2275
题意:给出3种颜色小球的数目,两种不同颜色的小球能可以变为另一种颜色的小球,问能 否转化为一种小球,最少需要几步
分两种情况,第一种有两种小球的数目一样可以,第二种两种小球的数目之差为三的倍数
#include<stdio.h>#include<string.h>#include<algorithm>using namespace std;int main(){int a[4];while(scanf("%d%d%d",&a[1],&a[2],&a[3])!=EOF){sort(a+1,a+4);if(a[1]==a[2]||(a[2]-a[1])%3==0)printf("%d\n",a[2]); else if(a[1]==a[3]||a[2]==a[3]||(a[3]-a[1])%3==0||(a[3]-a[2])%3==0)printf("%d\n",a[3]);elseprintf("):\n");}return 0;}
0 0
- hdu 2277 Change the ball(找规律)
- HDU 2277 Change the ball(找规律)
- hdoj 2277 Change the ball 【找规律】
- hdoj 2277 Change the ball 【找规律】
- hdoj 2277 Change the ball 【找规律】
- 【杭电oj】2277 - Change the ball(找规律)
- HDOJ 题目2277 Change the ball(水题,规律)
- hdoj-2277-Change the ball【规律】
- hdoj 2277 Change the ball【规律题】
- hdu-2277-Change the ball
- HDU-2277 Change the ball
- HDU-2277 Change the ball
- HDU-#4811Ball(找规律)
- HDU:2277 Change the ball(水)(数学)
- 2277 Change the ball
- hdoj 2277 Change the ball
- hdu (找规律)
- 找规律:String Change
- ConcurrentHashMap原理分析
- RecyclerView单选
- 默认函数
- hibernate的核心类和接口(2)
- Ubuntu14.04下安装oracle JDK32位。并更换默认jdk
- HDU 2277 Change the ball(找规律)
- codeforces #343 C. Famil Door and Brackets (dp)
- PB控件TreeView的四个函数
- 数据结构2.2
- 杭电Acm1015
- for、while
- 安卓开发环境搭建常遇到的问题与总结
- 用Tensorflow基于Deep Q Learning DQN 玩Flappy Bird
- 初识CAPWAP