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 ...
随机推荐
- linux commond
1 vi /etc/sysconfig/network-scripts/ifcfg-eth0 2 ifconfig 3 ping 172.22.14.59 4 ping 1 ...
- GitHub 中国区前100 名技术专家
[本文是在一片新闻上摘录的,原地址为:http://mt.sohu.com/20160407/n443539407.shtml] 本文根据Github公开API,抓取了地址显示China的用户,根据粉 ...
- Java事务处理总结
http://lavasoft.blog.51cto.com/62575/53815/ 一.什么是Java事务 通常的观念认为,事务仅与数据库相关. 事务必须服从ISO/IEC所制定的ACID ...
- bootstrap 的 datetimepicker 结束时间大于开始时间
web的时间js控件,在管理性的项目中频繁用到,总结了一些用到的知识,分享出来,供以后学习: 1.首先引用资源包: bootstrap基础资源包: bootstrap.min.css .bootstr ...
- windows下用过VMware安装MAC OS X苹果系统
vmware怎么安装os x10.9?vmware 10安装mac os 10.9教程详解 来源:互联网 作者:佚名 时间:10-30 13:50:20 [大 中 小] VMWare 虚拟机可以使你在 ...
- MySQL支持多种存储引擎
MySQL的强大之处在于它的插件式存储引擎,我们可以基于表的特点使用不同的存储引擎,从而达到最好的性能. MySQL有多种存储引擎:MyISAM.InnoDB.MERGE.MEMORY(HEAP).B ...
- 全面认识网络诊断命令功能与参数——netsh diagnostic命令
netsh diagnostic是网络诊断命令,主要检测网络连接和服务器连接的状态. 注意:netsh不能在Window2000以下系统中使用.案例1:使用netsh diagnostic命令检 ...
- WCF与Web API 区别(应用场景)
Web api 主要功能: 支持基于Http verb (GET, POST, PUT, DELETE)的CRUD (create, retrieve, update, delete)操作 请求的回 ...
- LeetCode FindMinimuminRotatedSorteArray &&FindMinimuminRotatedSorteArray2
LeetCode上这两道题主要是使用二分搜索解决,是二分搜索算法的一个应用,根据条件每次舍弃一半,保留一半. 首先第一题: FindMinimuminRotatedSorteArray(时间复杂度为二 ...
- MySQL5.7 linux二进制安装
200 ? "200px" : this.width)!important;} --> 介绍 MySQL5.7出来也有大半年了,业内也一直在宣传5.7有多么的N,官网的也是宣 ...