Java实现 洛谷 P1328 生活大爆炸版石头剪刀布
import java.util.Scanner;
public class Main{
private static int[] duel(int playerA, int playerB){
int[] result = new int[2];
if (playerA == 0){
if (playerB == 1) result[1] = 1;
if (playerB == 2) result[0] = 1;
if (playerB == 3) result[0] = 1;
if (playerB == 4) result[1] = 1;
} else if (playerA == 1){
if (playerB == 0) result[0] = 1;
if (playerB == 2) result[1] = 1;
if (playerB == 3) result[0] = 1;
if (playerB == 4) result[1] = 1;
} else if (playerA == 2){
if (playerB == 0) result[1] = 1;
if (playerB == 1) result[0] = 1;
if (playerB == 3) result[1] = 1;
if (playerB == 4) result[0] = 1;
} else if (playerA == 3){
if (playerB == 0) result[1] = 1;
if (playerB == 1) result[1] = 1;
if (playerB == 2) result[0] = 1;
if (playerB == 4) result[0] = 1;
} else if (playerA == 4){
if (playerB == 0) result[0] = 1;
if (playerB == 1) result[0] = 1;
if (playerB == 2) result[1] = 1;
if (playerB == 3) result[1] = 1;
}
return result;
}
public static void main(String[] args){
Scanner input = new Scanner(System.in);
int n = input.nextInt();
int nA = input.nextInt();
int nB = input.nextInt();
int[] a = new int[nA];
int[] b = new int[nB];
for (int i = 0; i < nA; i++){
a[i] = input.nextInt();
}
for (int i = 0; i < nB; i++){
b[i] = input.nextInt();
}
int countA = 0;
int countB = 0;
for (int i = 0; i < n; i++){
countA = countA + duel(a[i % nA], b[i % nB])[0];
countB = countB + duel(a[i % nA], b[i % nB])[1];
}
System.out.println(countA + " " + countB);
}
}
Java实现 洛谷 P1328 生活大爆炸版石头剪刀布的更多相关文章
- 洛谷P1328 生活大爆炸版石头剪刀布——S.B.S.
题目描述 石头剪刀布是常见的猜拳游戏:石头胜剪刀,剪刀胜布,布胜石头.如果两个人出拳一样,则不分胜负.在<生活大爆炸>第二季第8 集中出现了一种石头剪刀布的升级版游戏. 升级版游戏在传统的 ...
- [NOIP2014] 提高组 洛谷P1328 生活大爆炸版石头剪刀布
题目描述 石头剪刀布是常见的猜拳游戏:石头胜剪刀,剪刀胜布,布胜石头.如果两个人出拳一样,则不分胜负.在<生活大爆炸>第二季第8 集中出现了一种石头剪刀布的升级版游戏. 升级版游戏在传统的 ...
- 洛谷 P1328 生活大爆炸版石头剪刀布【模拟/环/周期】
题目描述 石头剪刀布是常见的猜拳游戏:石头胜剪刀,剪刀胜布,布胜石头.如果两个人出拳一样,则不分胜负.在<生活大爆炸>第二季第8 集中出现了一种石头剪刀布的升级版游戏. 升级版游戏在传统的 ...
- 洛谷—— P1328 生活大爆炸版石头剪刀布
https://www.luogu.org/problem/show?pid=1328 题目描述 石头剪刀布是常见的猜拳游戏:石头胜剪刀,剪刀胜布,布胜石头.如果两个人出拳一样,则不分胜负.在< ...
- 洛谷P1328生活大爆炸版石头剪刀布
题目链接:https://www.luogu.org/problemnew/show/P1328
- 洛谷 P1328 生活大爆炸版石头剪刀布 —— 模拟
题目:https://www.luogu.org/problemnew/show/P1328 直接模拟即可. 代码如下: #include<iostream> #include<cs ...
- 洛谷 P1328 生活大爆炸版石头剪刀布 模拟
很简单 Code: #include<cstdio> #include<queue> using namespace std; queue<int>A; queue ...
- 洛谷 1328 生活大爆炸版石头剪刀布(NOIp2014提高组)
[题解] 简单粗暴的模拟题. #include<cstdio> #include<algorithm> #include<cstring> #define LL l ...
- 模拟--P1328 生活大爆炸版石头剪刀布 题解
P1328 生活大爆炸版石头剪刀布 这也是打表么?? #include <iostream> using namespace std; static const auto y = []() ...
随机推荐
- Istio的流量管理(实操一)(istio 系列三)
Istio的流量管理(实操一)(istio 系列三) 使用官方的Bookinfo应用进行测试.涵盖官方文档Traffic Management章节中的请求路由,故障注入,流量迁移,TCP流量迁移,请求 ...
- vscode+eslint自动格式化vue代码的方法
前言 使用vscode开发vue项目的时候,为了编码格式的统一化,使用eslint规范进行格式化.此时通过eslint插件可以实现对vue代码的自动格式化. 使用方式 在vscode的插件模块处,搜索 ...
- 初识spring boot maven管理--SpringMVC
springboot完美的支持了springmvc,自家东西当然是支持最好的啦! @EnableAutoConfiguration自动注入了一下信息 1.包含了ContentNegotiatingVi ...
- 「雕爷学编程」Arduino动手做(32)——雨滴传感器模块
37款传感器与模块的提法,在网络上广泛流传,其实Arduino能够兼容的传感器模块肯定是不止37种的.鉴于本人手头积累了一些传感器和模块,依照实践出真知(一定要动手做)的理念,以学习和交流为目的,这里 ...
- spark机器学习从0到1奇异值分解-SVD (七)
降维(Dimensionality Reduction) 是机器学习中的一种重要的特征处理手段,它可以减少计算过程中考虑到的随机变量(即特征)的个数,其被广泛应用于各种机器学习问题中,用于消除噪声 ...
- Java基础之值传递
一.传递类型 我们从c语言开始学习程序设计语言时就知道,参数的传递类型一般有两种:值传递和引用传递.那么什么是值传递什么是引用传递呢? 值传递:指在调用方法时将实际参数的值拷贝一份传递给方法,这样方法 ...
- nginx配置之状态模块和压力测试功能
状态模块功能 nginx.conf中的http{}中的server{}中: location /status { #开启nginx状态功能 stub_status on; } 直接在网页中请求stat ...
- SWPU邮件登录界面的仿写(第二次作业)
(一).检查并下载网页元素 在需仿写的页面按F12,点击element,寻找需要的图片元素. (二). 分析网页的布局 查看网页源代码. (三).开始仿写 由于我们的目标是仿写网页,所以可以直接复制网 ...
- 设置键盘return键样式
textField.returnKeyType = UIReturnKeySend; typedef NS_ENUM(NSInteger, UIReturnKeyType) { UIReturnKey ...
- UVALive3720
题目大意:见刘汝佳<算法竞赛入门经典——训练指南>P173. 解题思路: 问题可以转化为求共有多少条过点阵中的点的斜线.其中必定包含左斜线和右斜线,由于点阵式对称的,所以我们只需求出左右斜 ...