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. bzoj1052 [HAOI2007]覆盖问题 - 贪心

    Description 某人在山上种了N棵小树苗.冬天来了,温度急速下降,小树苗脆弱得不堪一击,于是树主人想用一些塑料薄膜把这些小树遮盖起来,经过一番长久的思考,他决定用3个L*L的正方形塑料薄膜将小 ...

  2. TYVJ1716 上帝造题的七分钟

    时间: 1000ms / 空间: 131072KiB / Java类名: Main 背景 裸体就意味着身体. 描述 “第一分钟,X说,要有矩阵,于是便有了一个里面写满了0的n×m矩阵.第二分钟,L说, ...

  3. Ajax核心知识(2)

    对于Ajax核心的东西需要在进行总结提炼一下: xmlHttp对象. 方法:xml.responseText获取后台传递到前台的数据,经常性的使用var object=xml.responseText ...

  4. openstack setup demo Compute service

    本文包含以下部分 Compute service overview Install and configure controller node Prerequisites Install and co ...

  5. SSH端口自定义

    SSH的服务端口是22,可以定义成其他端口号, / etc/ssh/sshd_config   #ssh-server配置文件位于 /etc/init.d/ssh start   #重启SSH服务,

  6. LintCode 近期公共祖先

    中等 近期公共祖先 查看执行结果 34% 通过 给定一棵二叉树,找到两个节点的近期公共父节点(LCA). 近期公共祖先是两个节点的公共的祖先节点且具有最大深度. 您在真实的面试中是否遇到过这个题? Y ...

  7. hdu 5253 连接的管道(kruskal)(2015年百度之星程序设计大赛 - 初赛(2))

    连接的管道 Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Subm ...

  8. 分析Linux内核的启动过程

    第一章 环境 Ubuntu 14.10 Linux Kernel 3.18.6 第二章 代码及调试过程 环境搭建与内核准备: cd ~/LinuxKernel/ wget https://www.ke ...

  9. web 开发之js---js 中的数组操作

    js数组元素的添加和删除一直比较迷惑,今天终于找到详细说明的资料了,先给个我测试的代码^-^var arr = new Array();arr[0] = "aaa";arr[1] ...

  10. Restful WebService简介

    RESTful Web Services已经渐渐開始流行, 主要是用于解决异构系统之间的通信问题.非常多站点和应用提供的API,都是基于RESTful风格的Web Services,比較就有Googl ...