【HDU 1889】Reaux! Sham! Beaux!(模拟+水题)

传送门:http://acm.hdu.edu.cn/showproblem.php?pid=1889

题意:给出一个表,每个国家的石头剪子布的叫法,给两个人用自己国家的语言进行石头剪子布,进行统计,最后输出胜负信息。

分析:就是模拟,先用map去映射每一个字符串,3种分别为1,2,3,然后进行统计判定即可,注意坑点就是输出时候有单复数区别,还有输出格式比较容易错。

代码:

/* ***********************************************
Author        :Torrance_ZHANG
Created Time  :2016/5/2 15:04:40
File Name     :ceshi.cpp
************************************************ */

#include<iostream>
#include<stdio.h>
#include<queue>
#include<string.h>
#include<math.h>
#include<string>
#include<map>
using namespace std;
map<string,int>mm;
struct Node{
    string name;
    string nation;
    Node(string a="",string b=""):name(b),nation(a){}
};
void init(){
    mm["Kamen"]=mm["Rock"]=mm["Pierre"]=mm["Stein"]=mm["Ko"]=mm["Koe"]=mm["Sasso"]=mm["Roccia"]=mm["Guu"]=mm["Kamien"]=mm["Piedra"]=1;
    mm["Nuzky"]=mm["Scissors"]=mm["Ciseaux"]=mm["Schere"]=mm["Ollo"]=mm["Olloo"]=mm["Forbice"]=mm["Choki"]=mm["Nozyce"]=mm["Tijera"]=2;
    mm["Papir"]=mm["Paper"]=mm["Feuille"]=mm["Papier"]=mm["Papir"]=mm["Carta"]=mm["Rete"]=mm["Paa"]=mm["Papier"]=mm["Papel"]=3;
}
int main(){
    string a,b;
    init();
    int id=1;
    bool flag=false;
    while(cin>>a>>b){
        Node na(a,b);
        cin>>a>>b;
        Node nb(a,b);
        string op;
        int num[5]={0};
        while(cin>>op){
            if(!flag){
                if(op=="-"||op=="."){
                    cout<<"Game #"<<id++<<":"<<endl;
                    cout<<na.name<<": "<<num[1]<<" point" << (num[1]==1?"":"s")<<endl;
                    cout<<nb.name<<": "<<num[2]<<" point"<<(num[2]==1?"":"s")<<endl;
                    if(num[1]==num[2])
                        cout<<"TIED GAME"<<endl;
                    else if(num[1]>num[2]){
                        cout<<"WINNER: "<<na.name<<endl;
                    }
                    else if(num[1]<num[2]){
                        cout<<"WINNER: "<<nb.name<<endl;
                    }
                    cout<<endl;
                    if(op=="."){
                        flag=true;
                    }
                    break;
                } else{
                    string op2;
                    cin>>op2;
                    if(mm[op]!=mm[op2]){
                        if(mm[op]==1&&mm[op2]==2){
                            num[1]++;
                        }
                        else if(mm[op]==1&&mm[op2]==3){
                            num[2]++;
                        }
                        else if(mm[op]==2&&mm[op2]==1){
                            num[2]++;
                        }
                        else if(mm[op]==2&&mm[op2]==3){
                            num[1]++;
                        }
                        else if(mm[op]==3&&mm[op2]==1){
                            num[1]++;
                        }
                        else if(mm[op]==3&&mm[op2]==2){
                            num[2]++;
                        }
                    }
                }
            }
        }
        if(flag)
            return 0;
    }
}
时间: 2024-10-26 03:41:46

【HDU 1889】Reaux! Sham! Beaux!(模拟+水题)的相关文章

HDU 6213 Chinese Zodiac 【模拟/水题/生肖】

[题意]:一个女的找了一个比自己小的丈夫,没有人知道他们的年领差,但是知道他们的十二生肖.问女的至少比男的大多少岁. [分析]如果两人属相相同,肯定大一轮,就是12. 如果女的属相比男的靠后,则就是12-(女的属相-男的属相) 如果女的属相比男的靠前,则就是(男的属相-女的属相) [代码]: 15MS 1948K #include <iostream> #include<cstdio> #include<algorithm> #include<cstring>

HDOJ 2317. Nasty Hacks 模拟水题

Nasty Hacks Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 3049    Accepted Submission(s): 2364 Problem Description You are the CEO of Nasty Hacks Inc., a company that creates small pieces of

HDU 1862 EXCEL排序 (排序水题)

Problem Description Excel可以对一组纪录按任意指定列排序.现请你编写程序实现类似功能. Input 测试输入包含若干测试用例.每个测试用例的第1行包含两个整数 N (<=100000) 和 C,其中 N 是纪录的条数,C 是指定排序的列号.以下有 N 行,每行包含一条学生纪录.每条学生纪录由学号(6位数字,同组测试中没有重复的学号).姓名(不超过8位且不包含空格的字符串).成绩(闭区间[0, 100]内的整数)组成,每个项目间用1个空格隔开.当读到 N=0 时,全部输入结

HDU 4007 Dave (基本算法-水题)

Dave Problem Description Recently, Dave is boring, so he often walks around. He finds that some places are too crowded, for example, the ground. He couldn't help to think of the disasters happening recently. Crowded place is not safe. He knows there

POJ 3030. Nasty Hacks 模拟水题

Nasty Hacks Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 13136   Accepted: 9077 Description You are the CEO of Nasty Hacks Inc., a company that creates small pieces of malicious software which teenagers may use to fool their friends.

HDU 1800 Flying to the Mars (水题)

Flying to the Mars Time Limit: 5000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 11099    Accepted Submission(s): 3572 Problem Description In the year 8888, the Earth is ruled by the PPF Empire . As the popul

HDU 1520 Anniversary party 树DP水题

非常水的树DP,状态为当前为i,上级来没来 然后跑一遍记忆化搜索即可 #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> #include <climits> #include <string> #include <iostream> #include <map> #include <cstdlib>

HDU 4022 Bombing(基本算法-水题)

Bombing Problem Description It's a cruel war which killed millions of people and ruined series of cities. In order to stop it, let's bomb the opponent's base. It seems not to be a hard work in circumstances of street battles, however, you'll be encou

HDU 5344 MZL&#39;s xor(水题)

MZL's xor Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 456    Accepted Submission(s): 322 Problem Description MZL loves xor very much.Now he gets an array A.The length of A is n.He wants to