Chinese Zodiac

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

Total Submission(s): 2451    Accepted Submission(s): 1645


Problem Description
The Chinese Zodiac, known as Sheng Xiao, is based on a twelve-year cycle, each year in the cycle related to an animal sign. These signs are the rat, ox, tiger, rabbit, dragon, snake, horse, sheep, monkey, rooster, dog and pig.

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.
 

Input
The first line of input contains an integer T (1≤T≤1000) indicating
the number of test cases.

For each test case a line of two strings describes the signs of Victoria and her husband.
 

Output
For each test case output an integer in a line.
 

Sample Input

3
ox rooster
rooster ox
dragon dragon
 

Sample Output

8
4
12
 

Source

输入输出测试
 

Statistic | Submit | Clarifications | Back

题意:十二生肖大循环

思路:比较水

#include <iostream>
#include<vector>
#include<string>
using namespace std; int main()
{
vector< string>vec;
vec.push_back("rat");
//vec[0].second=1;
vec.push_back("ox");
//vec[1].second=2;
vec.push_back("tiger");
//vec[2].second=3;
vec.push_back("rabbit");
//vec.push_back("monkey");
vec.push_back("dragon");
vec.push_back("snake");
vec.push_back("horse");
vec.push_back("sheep");
vec.push_back("monkey");
vec.push_back("rooster");
vec.push_back("dog");
vec.push_back("pig"); int t;
cin>>t;
while(t--)
{
string str1,str2;
cin>>str1>>str2;
int cnt1,cnt2;
for(int i=0;i<=11;i++)
{
if(vec[i]==str1)
{
cnt1=i+1;
break;
}
}
for(int j=0;j<=11;j++)
{ if(vec[j]==str2)
{
cnt2=j+1;
break;
}
}
if(cnt2-cnt1>0)
cout<<cnt2-cnt1<<endl;
else
cout<<cnt2-cnt1+12<<endl;
}
}

2017青岛网络赛1008 Chinese Zodiac的更多相关文章

  1. HDU 6212 Zuma 2017青岛网络赛 区间DP

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6212 解法:看了眼题就发现这个BZOJ 1032不是一毛一样?但是BZOJ上那是个巨坑,数据有错,原来 ...

  2. 2017青岛网络赛1011 A Cubic number and A Cubic Number

    A Cubic number and A Cubic Number Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 65535/3276 ...

  3. 2017 青岛网络赛 Chenchen, Tangtang and ZengZeng

    Chenchen, Tangtang and ZengZeng are starting a game of tic-tac-toe, played on a 3 × 3 board. Initial ...

  4. 2017 ACM/ICPC Asia Regional Qingdao Online - 1008 Chinese Zodiac

    2017-09-17 13:28:04 writer:pprp 签到题:1008 Chinese Zodiac #include <iostream> #include <strin ...

  5. HDU 4745 Two Rabbits (2013杭州网络赛1008,最长回文子串)

    Two Rabbits Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 65535/65535 K (Java/Others)Tota ...

  6. HDU 5880 Family View (2016 青岛网络赛 C题,AC自动机)

    题目链接  2016 青岛网络赛  Problem C 题意  给出一些敏感词,和一篇文章.现在要屏蔽这篇文章中所有出现过的敏感词,屏蔽掉的用$'*'$表示. 建立$AC$自动机,查询的时候沿着$fa ...

  7. 2017乌鲁木齐网络赛 j 题

    题目连接 : https://nanti.jisuanke.com/t/A1256 Life is a journey, and the road we travel has twists and t ...

  8. hdu 6152 : Friend-Graph (2017 CCPC网络赛 1003)

    题目链接 裸的结论题.百度 Ramsey定理.刚学过之后以为在哪也不会用到23333333333,没想到今天网络赛居然出了.顺利在题面更改前A掉~~~(我觉得要不是我开机慢+编译慢+中间暂时死机,我还 ...

  9. 2017 ICPC网络赛(西安)--- Xor

    题目连接 Problem There is a tree with n nodes. For each node, there is an integer value ai, (1≤ai​≤1,000 ...

随机推荐

  1. [NOIP2004] 提高组 洛谷P1089 津津的储蓄计划

    题目描述 津津的零花钱一直都是自己管理.每个月的月初妈妈给津津300元钱,津津会预算这个月的花销,并且总能做到实际花销和预算的相同. 为了让津津学习如何储蓄,妈妈提出,津津可以随时把整百的钱存在她那里 ...

  2. 【small项目】MySQL第二天早上第一次连接超时报错,解决方法com.mysql.jdbc.exceptions.jdbc4.CommunicationsException:

    MySQL第二天早上第一次连接超时报错,解决方法com.mysql.jdbc.exceptions.jdbc4.CommunicationsException: Communications link ...

  3. <a href="ip地址" target=""_blank">a里面的target</a>

    HTML <a> 标签的 target 属性 定义和用法 <a> 标签的 target 属性规定在何处打开链接文档. 如果在一个 <a> 标签内包含一个 targe ...

  4. 【剑指Offer面试题】 九度OJ1385:重建二叉树

    题目链接地址: pid=1385">http://ac.jobdu.com/problem.php?pid=1385 题目1385:重建二叉树 时间限制:1 秒内存限制:32 兆特殊判 ...

  5. java.lang.IllegalArgumentException: sheetName &#39;&#39; is invalid

    1.错误描写叙述 java.lang.IllegalArgumentException: sheetName '' is invalid - character count MUST be great ...

  6. 秒懂C#通过Emit动态生成代码 C#使用Emit构造拦截器动态代理类

    秒懂C#通过Emit动态生成代码   首先需要声明一个程序集名称, 1 // specify a new assembly name 2 var assemblyName = new Assembly ...

  7. 使用heartbeat+monit实现主备双热备份系统

    一.使用背景 项目须要实现主备双热自己主动切换的功能,保证系统7*24小时不间断执行.现已有两台双网卡的IBM的server,为了不再添加成本採购独立外部存储设备和双机热备软件.採用了linux下开源 ...

  8. uva 10452 Marcus

    Problem I Marcus, help! Input: standard input Output: standard output Time Limit: 2 Seconds "Fi ...

  9. Android 4.4.2 动态加入JNI库方法记录 (一 JNI库层)

    欢迎转载,务必注明出处.http://blog.csdn.net/wang_shuai_ww/article/details/44456755 本篇是继<s5p4418 Android 4.4. ...

  10. c# DataGridView样式设置无效

    对DataGridView中的某些行设置样式时,无效,最后发现,我是先设置完样式再进行展现的this.controls.Add,应该先展现完了,再设置样式.