博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
杭电2277--Change the ball
阅读量:6671 次
发布时间:2019-06-25

本文共 2268 字,大约阅读时间需要 7 分钟。

Change the ball

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 564    Accepted Submission(s): 198

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?
 

 

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 3
1 2 2
 

 

Sample Output
):
2
 

 

Source
 

 

Recommend
lcy   |   We have carefully selected several similar problems for you:            
分析:三个数中只要有两个数之差为3的倍数就可以完成转化; 转化次数为num=max(a, b); 结果为min(num) ; 
1 #include 
2 #include
3 #include
4 #define max(a,b) a>b?a:b 5 using namespace std; 6 int main() 7 { 8 9 int a, b, c;10 int i, total;11 12 while(~scanf("%d %d %d", &a, &b, &c))13 {14 total = 0;15 int num[3] = {
0, 0, 0};16 if(abs(a-b)%3==0)17 num[total] += max(a,b);18 total++;19 if(abs(b-c)%3==0)20 num[total] += max(b,c);21 total++;22 if(abs(a-c)%3==0)23 num[total] += max(a,c);24 total++;25 if(num[0]==0 && num[1]==0 && num[2]==0)26   printf("):\n");27 else28 {29 sort(num, num+3);30 for(i=0; i<3; i++)31 {32 if(num[i] != 0)33 {34 printf("%d\n",num[i]);35 break; 36 }37 }38 }39 }40 return 0;41 }

 

 

转载于:https://www.cnblogs.com/soTired/p/4677421.html

你可能感兴趣的文章
东方日升拉美光伏电站项目 将进入首期施工
查看>>
软件探索性测试 笔记二
查看>>
将来也不会被破译的分布式存储系统
查看>>
光伏电站或成辅助服务市场“输家”
查看>>
今年光伏“领跑者”计划将升级扩围
查看>>
Java程序运行超时后退出或进行其他操作的实现
查看>>
手把手教你启用RemoteFX以及Hyper-V GPU卸载
查看>>
《交互式程序设计 第2版》一3.10 更进一步
查看>>
英伟达发布Tesla P4&P40两款基于Pascal架构的深度学习芯片
查看>>
《ANSYS Workbench有限元分析实例详解(静力学)》——2.5 Windows界面相应操作
查看>>
《代码整洁之道:程序员的职业素养》一一1.3 首先,不行损害之事
查看>>
intellij 创建java web项目(maven管理的SSH)
查看>>
spring-java项目中连接redis数据库
查看>>
UML介绍--用例图
查看>>
阿里云DTS VS MySQLdump
查看>>
为android封装的百度定位组件
查看>>
我的友情链接
查看>>
Linux系统新手学习的11点建议
查看>>
Android SDK:构建一个购物中心搜索的应用(二)-Points of Interest
查看>>
查询oracle数据库编码
查看>>