1090-Rock, Paper, Scissors
描述
Rock, Paper, Scissors is a classic hand game for two people. Each participant holds out either a fist (rock), open hand (paper), or two-finger V (scissors). If both players show the same gesture, they try again. They continue until there are two different gestures. The winner is then determined according to the table below: Rock beats Scissors Paper beats Rock
Scissors beats Paper Your task is to take a list of symbols representing the gestures of two players and determine how many games each player wins. In the following example:
Turn : 1 2 3 4 5
Player 1 : R R S R S
Player 2 : S R S P S
Player 1 wins at Turn 1 (Rock beats Scissors), Player 2 wins at Turn 4 (Paper beats Rock), and all the other turns are ties.
输入
The input contains between 1 and 20 pairs of lines, the first for Player 1 and the second for Player 2. Both player lines contain the same number of symbols from the set {'R', 'P', 'S'}. The number of symbols per line is between 1 and 75, inclusive. A pair of lines each containing the single character 'E' signifies the end of the input.
输出
For each pair of input lines, output a pair of output lines as shown in the sample output, indicating the number of games won by each player.
样例输入
RRSRS
SRSPS
PPP
SSS
SPPSRR
PSPSRS
E
E
样例输出
P1: 1
P2: 1
P1: 0
P2: 3
P1: 2
P2: 1
#include<iostream>
#include<string>
using namespace std; void compare(char a,char b,int &count1,int &count2)
{
if(a=='R')
{
if(b=='S') count1++;
if(b=='P') count2++;
}
if(a=='P')
{
if(b=='R') count1++;
if(b=='S') count2++;
}
if(a=='S')
{
if(b=='P') count1++;
if(b=='R') count2++;
}
}
int main()
{
string s1,s2;
while(cin>>s1>>s2&&(s1!="E"&&s2!="E"))
{
int len=s1.length();
int i;
int count1=0;
int count2=0;
for(i=0;i<len;i++)
{
compare(s1[i],s2[i],count1,count2);
}
cout<<"P1: "<<count1<<endl;
cout<<"P2: "<<count2<<endl;
}
return 0;
}
1090-Rock, Paper, Scissors的更多相关文章
- 2018 ACM-ICPC 中国大学生程序设计竞赛线上赛 H题 Rock Paper Scissors Lizard Spock.(FFT字符串匹配)
2018 ACM-ICPC 中国大学生程序设计竞赛线上赛:https://www.jisuanke.com/contest/1227 题目链接:https://nanti.jisuanke.com/t ...
- SDUT 3568 Rock Paper Scissors 状压统计
就是改成把一个字符串改成三进制状压,然后分成前5位,后5位统计, 然后直接统计 f[i][j][k]代表,后5局状压为k的,前5局比和j状态比输了5局的有多少个人 复杂度是O(T*30000*25*m ...
- FFT(Rock Paper Scissors Gym - 101667H)
题目链接:https://vjudge.net/problem/Gym-101667H 题目大意:首先给你两个字符串,R代表石头,P代表布,S代表剪刀,第一个字符串代表第一个人每一次出的类型,第二个字 ...
- Gym - 101667H - Rock Paper Scissors FFT 求区间相同个数
Gym - 101667H:https://vjudge.net/problem/Gym-101667H 参考:https://blog.csdn.net/weixin_37517391/articl ...
- Gym101667 H. Rock Paper Scissors
将第二个字符串改成能赢对方时对方的字符并倒序后,字符串匹配就是卷积的过程. 那么就枚举字符做三次卷积即可. #include <bits/stdc++.h> struct Complex ...
- 【题解】CF1426E Rock, Paper, Scissors
题目戳我 \(\text{Solution:}\) 考虑第二问,赢的局数最小,即输和平的局数最多. 考虑网络流,\(1,2,3\)表示\(Alice\)选择的三种可能性,\(4,5,6\)同理. 它们 ...
- 题解 CF1426E - Rock, Paper, Scissors
一眼题. 第一问很简单吧,就是每个 \(\tt Alice\) 能赢的都尽量让他赢. 第二问很简单吧,就是让 \(\tt Alice\) 输的或平局的尽量多,于是跑个网络最大流.\(1 - 3\) 的 ...
- HDOJ(HDU) 2164 Rock, Paper, or Scissors?
Problem Description Rock, Paper, Scissors is a two player game, where each player simultaneously cho ...
- HDU 2164 Rock, Paper, or Scissors?
http://acm.hdu.edu.cn/showproblem.php?pid=2164 Problem Description Rock, Paper, Scissors is a two pl ...
随机推荐
- copy与deepcopy
对于 数字 和 字符串 而言,赋值.浅拷贝和深拷贝无意义,因为其永远指向同一个内存地址. 对于字典.元祖.列表 而言,进行赋值.浅拷贝和深拷贝时,其内存地址的变化是不同的. 赋值,只是创建一个变量,该 ...
- Windows之vmware安装破解版错误汇总
A.错误: units specified don't exist, SHSUCDX can't install A.解决: 虚拟机配置->CD/DVD->IDE(0,0) B:错误: n ...
- RabbitMQ 原文译1.2--"Hello Word"
本系列文章均来自官网原文,属于个人翻译,如有雷同,权当个人归档,忽喷. .NET/C# RabbitMQ 客户端下载地址:https://github.com/rabbitmq/rabbitmq-do ...
- (ASP.net)利用Application对象制作简单聊天室
1.共四个页面,Default.aspx默认主页,Default2.aspx聊天室 default3.aspx显示用户列表,default4.aspx显示聊天内容,添加一个Global.asax全局程 ...
- Html5时钟的实现
最近准备把自己的博客装修一下,首先,先为自己设计一个时钟吧,希望博客园能够尽快发放给我使用js的权限! 自从看见了苹果设计的那款因为侵权而赔钱了时钟,我就决定我的时钟一定是要参考这个来设计了! 不得不 ...
- TCP/IP三次握手
题目: TCP建立连接的过程采用三次握手,已知第三次握手报文的发送序列号为1000,确认序列号为2000,请问第二次握手报文的发送序列号和确认序列号分别为 1999,999 1999,1000 999 ...
- Hudson的安装配置
Hudson的安装配置 目录 一.正文... 2 1.安装配置jdk. 2 2.安装配置tomcat7. 2 3.安装Hudson. 2 4.启动tomcat. 2 5.初识Hudson. 3 6 ...
- ios - cordova 简介
Cordova 是一个可以让 JS 与原生代码(包括 Android 的 java,iOS 的 Objective-C 等)互相通信的一个库,并且提供了一系列的插件类,比如 JS 直接操作本地数据库的 ...
- Flex布局新旧混合写法详解(兼容微信)
原文链接:https://www.usblog.cc/blog/post/justzhl/Flex布局新旧混合写法详解(兼容微信) flex是个非常好用的属性,如果说有什么可以完全代替 float 和 ...
- redis 实践—— sorted set, hash set
在这里就不谈redis的安装与启动啦,网上太多人写这个了. 从最近的一个项目[钻石夺宝]说起,如果大家有玩过一元夺宝或者全名夺宝的话,大概会知道如果参与人数多的话,每隔几秒.快的话每隔一秒都会新生成一 ...