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 ...
随机推荐
- Less入门学习总结
一.什么是Less css的Less好比是js的Jquery,可以让人们更方遍快捷的使用css,使css代码更简洁,可以减少重复的代码,减少开发人员的工作量. Less CSS是一种动态样式语言, ...
- 默认安装wamp修改MySQL密码
首先,通过WAMP打开mysql控制台. 提示输入密码,因为现在是空,所以直接按回车. 然后输入“use mysql”,意思是使用mysql这个数据库,提示“Database changed”就行. ...
- 隐藏NavigationBar 带来的坑
一.场景介绍 现在大多数APP 都有一个需求,就是隐藏某一个页面的NavigationBar.很多开发者直接 [self.navigationController setNavigationBar ...
- json转换(c#后台生成json的方法)
此文转自:http://bbs.csdn.net/topics/380200497,为了方便自己记忆才以文章形式保存. using System; using System.Collections.G ...
- C# 刷新当前窗体
在有多个窗体时,刷新当前激活的窗体 在MainForm.cs中: private void m_reflashtoolStripButton1_Click(object sender, EventAr ...
- OpenJudge 2813 画家问题 / Poj 1681 Painter's Problem
1.链接地址: http://bailian.openjudge.cn/practice/2813 http://poj.org/problem?id=1681 2.题目: 总时间限制: 1000ms ...
- 改善EF代码的方法(上)
本节,我们将介绍一些改善EF代码的相关方法,如NoTracking,GetObjectByKey, Include等. > MergeOption.NoTracking 当我们只需要读取某些数据 ...
- 【原创】开机出现grub rescue,修复办法
出现这种问题 一般在于进行了磁盘分区(GHOST备份时也会造成)导致grub引导文件找不到.我们只要让它找到引导文件就好了. 此时屏幕上提示grub resume> 我们先输入set看下现在g ...
- win7 蛋疼的时间格式转化
win7系统 获得系统时间为 2015年1月1日 星期5 10:10 数据库中时间格式 是不认识的 转化为 DateTime.Now.ToString("yyyy-MM-dd HH:mm:s ...
- winFrom窗体样式
ControlBox窗口样式:确定窗体是否有"控件/系统"菜单框. 设置为隐藏 False AutoSizeMode GrowAndShrink 指定用户界面元素自动调整自身大小 ...