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种结果).我们先从小的情况枚举找一 ...
随机推荐
- React学习笔记(三) 组件传值
组件嵌套后,父组件怎么向子组件发送数据呢? 答案是: this.props <script type="text/babel"> var MyFirst = React ...
- Mysql 操作手册
mysql操作手册 版本:5.6.16mysql linux安装基本步骤:#rpm -e --nodeps mysql-lib-5.1.*#rpm -ivh mysql-server#rpm -ivh ...
- C#.Net网页加载等待效果漂亮并且简单
最近网页加载数据比较多,点击后给用户就是白板很不友好,想了很久找了些资料,在网页加载中显示等待画面给客户,页面加载完成自动隐藏等待效果. 在网页后台cs代码: protected void Pa ...
- WPF DataGrid 行头小三角
<DataTemplate x:Key="RowHeaderTemplate"> <StackPanel Orientation="Horizontal ...
- DB2 WIN7 WIN8在指示的文件系统中找不到数据库目录
前言:win7下一些软件的不正常,跟win7的权限有很大关系. 在win7下安装db2 9.7客户端后,在cmd中运行db2cmd启动clp,输入db2的任何命令都显示:SQL ...
- yii2源码学习笔记(十六)
Module类的最后代码 /** * Registers sub-modules in the current module. * 注册子模块到当前模块 * Each sub-module shoul ...
- php函数的初步使用
通过调用函数,实现打印半金字塔.全金字塔.空心金字塔.菱形.空心菱形 调用例程 huaTuMain.php 被调用函数 huaTu.php
- Apache 禁止访问目录
1.打开apache配置文件httpd.conf 2.找到 <Directory /> Options Indexes AllowOverride None Order allow,den ...
- Android中通过typeface设置字体
Android系统默认支持三种字体,分别为:“sans”, “serif”, “monospace",除此之外还可以使用其他字体文件(*.ttf)方法一:XML中使用android默认字体 ...
- uboot的mtd功能支持
一.概述 1.MTD MTD是Flash的一种管理方法,将Flash划分成几个分区,便于管理. u-boot的MTD功能是在文件cmd_jffs2.c中实现的,由此我们可以知道怎样打开u-boot的M ...