zoukankan      html  css  js  c++  java
  • HDU 6213 Chinese Zodiac 【模拟/水题/生肖】

    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 (1T1000) 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
     

    【题意】:一个女的找了一个比自己小的丈夫,没有人知道他们的年领差,但是知道他们的十二生肖。问女的至少比男的大多少岁。

    【分析】如果两人属相相同,肯定大一轮,就是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"]=1;
            mp["ox"]=2;
            mp["tiger"]=3;
            mp["rabbit"]=4;
            mp["dragon"]=5;
            mp["snake"]=6;
            mp["horse"]=7;
            mp["sheep"]=8;
            mp["monkey"]=9;
            mp["rooster"]=10;
            mp["dog"]=11;
            mp[" pig"]=12;
            if(mp[f]==mp[m]) cout<<12<<endl;
            else if(mp[f]<mp[m]) cout<<abs(mp[f]-mp[m])<<endl;
            else cout<<12-abs(mp[f]-mp[m])<<endl;
        }
        return 0;
    }
    View Code
  • 相关阅读:
    wireshark抓包 TCP 字段详解
    youget使用教程
    JavaScript操作Oracle数据库
    WinForm导出文件,你懂的……
    Docker数据存储原理
    Dockerfile之CMD与ENTRYPOINT使用要点
    DevOps实战(Docker+Jenkins+Git)
    Python和Django web开发工具pycharm介绍
    连出两次
    python2.7发邮件小程序
  • 原文地址:https://www.cnblogs.com/Roni-i/p/7538360.html
Copyright © 2011-2022 走看看