HDU - 6213 Chinese Zodiac (2017 ACM-ICPC 亚洲区 (青岛赛区) 网络赛 1008)
2017-09-17 20:10
591 查看
2017 ACM/ICPC Asia Regional Qingdao Online 1008
Chinese Zodiac
Problem DescriptionThe 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
2017 ACM/ICPC Asia Regional Qingdao Online
#include<iostream> #include<deque> #include<memory.h> #include<stdio.h> #include<map> #include<string.h> #include<algorithm> #include<vector> #include<math.h> #include<stack> #include<queue> #include<set> using namespace std; int T; char buf[50],buf2[50]; int diff(int x){return (x>=0?x:-x);} int retr(char* buf){ if(strcmp(buf,"rat")==0)return 1; else if(strcmp(buf,"ox")==0)return 2; else if(strcmp(buf,"tiger")==0)return 3; else if(strcmp(buf,"rabbit")==0)return 4; else if(strcmp(buf,"dragon")==0)return 5; else if(strcmp(buf,"snake")==0)return 6; else if(strcmp(buf,"horse")==0)return 7; else if(strcmp(buf,"sheep")==0)return 8; else if(strcmp(buf,"monkey")==0)return 9; else if(strcmp(buf,"rooster")==0)return 10; else if(strcmp(buf,"dog")==0)return 11; else if(strcmp(buf,"pig")==0)return 12; } int main(){ scanf("%d",&T); int res; while(T--){ scanf("%s",buf); scanf("%s",buf2); if(retr(buf)==retr(buf2)){ res = 12; }else if(retr(buf)>retr(buf2)){ res = 12-retr(buf)+retr(buf2); }else { res = retr(buf2)-retr(buf); } printf("%d\n",res); } return 0; }
相关文章推荐
- HDU - 6214 Smallest Minimum Cut (2017 ACM-ICPC 亚洲区 (青岛赛区) 网络赛 1009)
- HDU - 6201 transaction transaction transaction (2017 ACM-ICPC 亚洲区 (沈阳赛区) 网络赛 1008)
- HDU - 6216 A Cubic number and A Cubic Number (2017 ACM-ICPC 亚洲区 (青岛赛区) 网络赛 1011)
- HDU - 6206 Apple (2017 ACM-ICPC 亚洲区 (青岛赛区) 网络赛 1001)
- HDU - 6208 The Dominator of Strings (2017 ACM-ICPC 亚洲区 (青岛赛区) 网络赛 1003)
- HDU - 6195 cable cable cable (2017 ACM-ICPC 亚洲区 (沈阳赛区) 网络赛 1002)
- HDU - 6198 number number number (2017 ACM-ICPC 亚洲区 (沈阳赛区) 网络赛 1005)
- HDU - 6197 array array array (2017 ACM-ICPC 亚洲区 (沈阳赛区) 网络赛 1004)
- HDU - 6205 card card card (2017 ACM-ICPC 亚洲区 (沈阳赛区) 网络赛 1012)
- 重要-- 模板 计蒜客-2017 ACM-ICPC 亚洲区(乌鲁木齐赛区)网络赛J题Our Journey of Dalian Ends (最小费用最大流)
- hdu 5883 The Best Path 2016ACM/ICPC青岛赛区网络赛1006
- 2017 ACM-ICPC 亚洲区(西安赛区)网络赛 E Maximum Flow
- 2017 ACM-ICPC 亚洲区(青岛赛区)网络赛 待补
- HDU6195 | 2017 ACM-ICPC 亚洲区(沈阳赛区)网络赛-B cable cable cable
- hihoCoder - 1586 Minimum (2017 ACM-ICPC 亚洲区 (北京赛区) 网络赛 I)
- hdu 5884 Sort 2016ACM/ICPC青岛赛区网络赛1007
- hdu 5889 Barricade 2016ACM/ICPC青岛赛区网络赛1011
- 计蒜客 2017 ACM-ICPC 亚洲区(西安赛区)网络赛 B coin(求乘法逆元)
- 2017 ACM-ICPC 亚洲区(北京赛区)网络赛
- 2017 ACM-ICPC 亚洲区(青岛赛区)网络赛 HDU 6206 1001 Apple(三角形外接圆圆心和半径)