hdoj 2277 Change the ball【找规律】
Change the ball
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 593 Accepted Submission(s):
207
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?
R(1<=Y,B,R<=1000),indicate the number refered above.
complete the assignment. If not, output the symbol “):”.
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
bool cmp(int a,int b)
{
return a>b;
}
int main()
{
int n,m,j,i,t;
int a[10];
int x,y;
while(scanf("%d%d%d",&a[0],&a[1],&a[2])!=EOF)
{
sort(a,a+3,cmp);
if(a[0]==a[1]||a[1]==a[2]||(a[1]-a[2])%3==0)
printf("%d\n",a[1]);
else if((a[0]-a[1])%3==0||(a[0]-a[2])%3==0)
printf("%d\n",a[0]);
else
printf("):\n");
}
return 0;
}
hdoj 2277 Change the ball【找规律】的更多相关文章
- HDU 2277 Change the ball
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2277 Change the ball Time Limit: 2000/1000 MS (Java/O ...
- Change the ball(找规律)
Change the ball Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)T ...
- 找规律/数位DP HDOJ 4722 Good Numbers
题目传送门 /* 找规律/数位DP:我做的时候差一点做出来了,只是不知道最后的 is_one () http://www.cnblogs.com/crazyapple/p/3315436.html 数 ...
- 数学--数论--HDU 1792 A New Change Problem (GCD+打表找规律)
Problem Description Now given two kinds of coins A and B,which satisfy that GCD(A,B)=1.Here you can ...
- codeforces D. Queue 找规律+递推
题目链接: http://codeforces.com/problemset/problem/353/D?mobile=true H. Queue time limit per test 1 seco ...
- HDU 4861 Couple doubi (数论 or 打表找规律)
Couple doubi 题目链接: http://acm.hust.edu.cn/vjudge/contest/121334#problem/D Description DouBiXp has a ...
- HDU 4861 Couple doubi(找规律|费马定理)
Couple doubi Time Limit:1000MS Memory Limit:32768KB 64bit IO Format:%I64d & %I64u Submit ...
- 计蒜客 39279.Swap-打表找规律 (The 2019 ACM-ICPC China Shannxi Provincial Programming Contest L.) 2019ICPC西安邀请赛现场赛重现赛
Swap There is a sequence of numbers of length nn, and each number in the sequence is different. Ther ...
- 随机序列[SHOI2016](找规律+线段树)
传送门 这道题的题意就是给你n个数让你在每个数之间插入+.-.*三种运算符中的一种,然后算出一个答案,再把答案加起来. 这题肯定是不能暴力的(题目都告诉你了由3n-1种结果).我们先从小的情况枚举找一 ...
随机推荐
- CoreAnimation
CoreAnimation 1.CABasicAnimation // position CABasicAnimation *ba = [CABasicAnimation animationWithK ...
- Objective-C发展历史
Objective-C发展历史 苹果图标由来: 被咬了一口苹果的LOGO是为了纪念计算机科学的创始人阿兰· 麦席森· 图灵.当年图灵由于身为同性恋者,被强行 "治疗",在被迫注射大 ...
- C蛮的全栈之路-node篇(二) 实战一:自动发博客
目录 C蛮的全栈之路-序章 技术栈选择与全栈工程师C蛮的全栈之路-node篇(一) 环境布置C蛮的全栈之路-node篇(二) 实战一:自动发博客 ---------------- 我是分割线 ---- ...
- Android DropBoxManager Service
Android DropBoxManager Service 什么是 DropBoxManager ? Enqueues chunks of data (from various sources – ...
- memcached在linux安装
服务器端主要是安装memcache服务器端.下载:http://www.danga.com/memcached/dist/memcached-1.2.2.tar.gz另外,Memcache用到了lib ...
- 对c++服务端进行覆盖率统计
(1)首先需要为每个被测程序的所有编译文件增加选项,如果文件太多,这无疑是灾难,可利用spec文件达到目的 sed -i '$ a\export LD_PRELOAD=/usr/local/bin/c ...
- URL encode 与 URL decode 的C语言实现
转载自:http://blog.csdn.net/langeldep/article/details/6264058 本文代码为从PHP代码中修改而来,只保留了2个函数. int php_url_de ...
- button 垂直分布
UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];//button的类型 button.frame = CGRectMak ...
- <meta http-equiv="pragma" content="no-cache"/>-备
<meta http-equiv="pragma" content="no-cache"/> 网页中常常看见有这样的标记,他们是清浏览器缓存用的啊, ...
- C#(MVC) Word 替换,填充表格,导出并下载PDF文档
近期做一个关于C# 操作 Word 模板 文档的功能模块,查阅资料,最终完美完成任务,记录下来,以便后面还会用到.