2017 icpc 青岛赛区 1008.Chinese Zodiac
来源:互联网 发布:什么叫手游数据 编辑:程序博客网 时间:2024/05/16 00:37
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 be2 years. But if the signs of the couple is the same, the answer should be 12 years.
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
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.
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
3ox roosterrooster oxdragon dragon
Sample Output
8412
Source
输入输出测试
水题;
【AC代码】
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;const int N=1005;int m,n;char s[][20]={"rat","ox","tiger","rabbit","dragon","snake","horse","sheep","monkey","rooster","dog","pig"};int main(){ int t; char s1[20],s2[20]; scanf("%d",&t); while(t--) { int p,q; scanf("%s%s",s1,s2); for(int i=0;i<12;i++) { if(strcmp(s1,s[i])==0) p=i; if(strcmp(s2,s[i])==0) q=i; } int ans=0; if(p==q) ans=12; else{ for(int i=p;i<12;++i) { if(strcmp(s[i],s2)!=0)ans++; else break; if(i==11) i=-1; } } printf("%d\n",ans); } return 0;}
阅读全文
0 0
- 2017 icpc 青岛赛区 1008.Chinese Zodiac
- 2017青岛网络赛1008 Chinese Zodiac
- Chinese Zodiac---ACM青岛Regional
- 2017 ACM/ICPC Asia Regional Qingdao Online--Chinese Zodiac
- 2017 ACM/ICPC Asia Regional Qingdao Online:1008 Chinese Zodiac
- 2017 ACM/ICPC 亚洲区域赛 青岛赛区
- hdu6206 Apple 2017icpc青岛赛区 java高精度类
- HDU6213 Chinese Zodiac 签到 2017 ACM/ICPC Asia Regional Qingdao Online
- 【2017 ACM/ICPC Asia Regional Qingdao Online 1008】hdu 6213 Chinese Zodiac
- HDU-2017 ACM/ICPC Asia Regional Qingdao Online-1008-Chinese Zodiac
- HDU6213 Chinese Zodiac STL水题 [2017 ACM/ICPC Asia Regional Qingdao Online]
- Chinese Zodiac
- Chinese Zodiac
- Chinese Zodiac
- Chinese Zodiac
- 2016ICPC青岛赛区网络赛 1001
- 2016ICPC青岛赛区网络赛 1002
- 2016ICPC青岛赛区网络赛 1004
- ajax(jsonp)发送ajax跨域请求
- VM12中CentOS7以NAT方式连接网络的方法
- mysql当前在线用户统计
- JQuery--导航
- JVM解析
- 2017 icpc 青岛赛区 1008.Chinese Zodiac
- 玩转接口测试工具fiddler 教程系列1
- 自定义控件
- 常用命令git
- Android—studio使用技巧
- 论文学习——Stereo Matching by Training a Convolutional Neural Network to Compare Image Patches
- 计算机组成原理与体系结构---层次化储存结构
- java异常
- C++文件读写详解(ofstream,ifstream,fstream)(转载)