HDU 6213 Chinese Zodiac 【模拟/水题/生肖】
Victoria is married to a younger man, but no one knows the real age difference between the couple. The good news is that she told us their Chinese Zodiac signs. Their years of birth in luner calendar is not the same. Here we can guess a very rough estimate of the minimum age difference between them.
If, for instance, the signs of Victoria and her husband are ox and rabbit respectively, the estimate should be 2
years. But if the signs of the couple is the same, the answer should be 12
years.
indicating the number of test cases.
For each test case a line of two strings describes the signs of Victoria and her husband.
ox rooster
rooster ox
dragon dragon
4
12
【题意】:一个女的找了一个比自己小的丈夫,没有人知道他们的年领差,但是知道他们的十二生肖。问女的至少比男的大多少岁。
【分析】如果两人属相相同,肯定大一轮,就是12.
如果女的属相比男的靠后,则就是12-(女的属相-男的属相)
如果女的属相比男的靠前,则就是(男的属相-女的属相)
【代码】:
| 15MS | 1948K |
#include <iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<map>
#include<set>
#include<string>
using namespace std; int main()
{
int t;
string f,m;
cin>>t;
map<string,int> mp;
/*rat, ox, tiger, rabbit, dragon, snake, horse, sheep, monkey, rooster, dog and pig.*/
while(t--)
{
cin>>f>>m;
mp["rat"]=;
mp["ox"]=;
mp["tiger"]=;
mp["rabbit"]=;
mp["dragon"]=;
mp["snake"]=;
mp["horse"]=;
mp["sheep"]=;
mp["monkey"]=;
mp["rooster"]=;
mp["dog"]=;
mp[" pig"]=;
if(mp[f]==mp[m]) cout<<<<endl;
else if(mp[f]<mp[m]) cout<<abs(mp[f]-mp[m])<<endl;
else cout<<-abs(mp[f]-mp[m])<<endl;
}
return ;
}
HDU 6213 Chinese Zodiac 【模拟/水题/生肖】的更多相关文章
- Chinese Zodiac (水题)
The Chinese Zodiac, known as Sheng Xiao, is based on a twelve-year cycle, each year in the cycle rel ...
- HDOJ 2317. Nasty Hacks 模拟水题
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- POJ 2014:Flow Layout 模拟水题
Flow Layout Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 3091 Accepted: 2148 Descr ...
- HDU 5578 Friendship of Frog 水题
Friendship of Frog Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.ph ...
- HDU 5590 ZYB's Biology 水题
ZYB's Biology Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.php?pid ...
- HDU 5538 L - House Building 水题
L - House Building Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://acm.hdu.edu.cn/showproblem.ph ...
- hdu 1005:Number Sequence(水题)
Number Sequence Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)T ...
- hdu 1018:Big Number(水题)
Big Number Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total ...
- hdu 2041:超级楼梯(水题,递归)
超级楼梯 Time Limit: / MS (Java/Others) Memory Limit: / K (Java/Others) Total Submission(s): Accepted Su ...
随机推荐
- 【bzoj2007】[Noi2010]海拔 最小割+对偶图+最短路
题目描述 YT市是一个规划良好的城市,城市被东西向和南北向的主干道划分为n×n个区域.简单起见,可以将YT市看作一个正方形,每一个区域也可看作一个正方形.从而,YT城市中包括(n+1)×(n+1)个交 ...
- [Leetcode] Best time to buy and sell stock 买卖股票的最佳时机
Say you have an array for which the i th element is the price of a given stock on day i. If you were ...
- number 解题报告
number 题目描述 给定整数 \(m,k\),求出正整数 \(n\) 使得 \(n+1,n+2,-,2n\) 中恰好有 \(m\) 个数在二进制下恰好有 \(k\) 个 \(1\). 有多组数据. ...
- CentOS 7, Attempting to create directory /root/perl5
By francis_hao Apr 10,2017 在使用CentOS 7的时候,首次登陆会出现新建一个perl5文件夹的提示,删除该文件后,之后登陆还是会出现该提示并新建了perl5文件夹. ...
- Spring源码解析-基于注解依赖注入
在spring2.5版本提供了注解的依赖注入功能,可以减少对xml配置. 主要使用的是 AnnotationConfigApplicationContext: 一个注解配置上下文 AutowiredA ...
- bzoj 2756 [SCOI2012]奇怪的游戏 二分+网络流
2756:[SCOI2012]奇怪的游戏 Time Limit: 40 Sec Memory Limit: 128 MBSubmit: 4926 Solved: 1362[Submit][Stat ...
- BAT定期删除N天前的文件
1.直接看脚本在win2008测试可用 ::clean logs @echo off title clean up logs ::delete logs FORFILES /P /C "cm ...
- Patch Windows with SSM on AWS
ec2ssmupdate https://docs.amazonaws.cn/systems-manager/latest/userguide/systems-manager-patch.htmlht ...
- 动态规划:树形DP
典型例题有三道: 没有上司的舞会 选课 景点中心 我们可以把动态规划的状态和转移描述成DAG 对于有根树来说,如果我们规定边的方向由父节点指向叶子节点 或者是由叶子节点指向父节点(奇葩) 那么它也是一 ...
- Ubuntu下hadoop集群搭建
--修改IP地址(克隆镜像后可修改可不修改) http://jingyan.baidu.com/article/e5c39bf5bbe0e739d7603396.html -------------- ...