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 = []() ...
随机推荐
- 数据库连接池Druid的介绍,配置分析对比总结
Druid的简介 Druid首先是一个数据库连接池.Druid是目前最好的数据库连接池,在功能.性能.扩展性方面,都超过其他数据库连接池,包括DBCP.C3P0.BoneCP.Proxool.JBos ...
- 关于oracle怎么看清楚字段的一些实践
在oracle存储过程或者平时编码中会有很多时候对不上字段,这时候在字段逗号后面可以主动加上--数字. 还有的是应该注意尽量让每个字段都占有一行的空间.下面部分截图说明
- 【白嫖】IT笔试面试真题讲解系列文章+视频
视频讲解IT公司面试的高频考题~ 持续更新中,欢迎点赞转发~ 干货|名企高频考点指令篇-查看Linux硬盘空间使用情况 干货 | 名企高频考点指令篇-Linux查看CPU内存和系统版本 干货 | 名企 ...
- 如何使用Postman生成不同格式测试的报告
Postman还可以生成测试报告,还是多种格式报告? Postman团队开源Newman作为Postman运营工具,该开源库使用命令行方式执行Postman 脚本,并且生成多种格式报告,还支持Post ...
- 3.7 Go指针
1. Go指针 每个变量在运行时都拥有一个地址,这个地址代表变量在内存中的位置. Go 语言中使用&作符放在变量前面对变量进行“取地址”操作. 1.指针默认值nil 2.通过&(取地值 ...
- C# DataTable转为TXT文档
public static void SaveCSV(DataTable dt, string fullPath) { var fi = new FileInfo(fullPath); if (!fi ...
- PG 慢日志分析工具pgbadger
失效地址 https://github.com/dalibo/pgbadger https://github.com/darold/pgbadger https://blog.csdn.net/cty ...
- el-table合理应用ref属性,使el-input获得焦点
全篇不着一丝文字痕迹,仅记录而已
- python基本数据类型;字符串及其方法三:
###################判断类型################### ######################################################### ...
- vscode环境配置(三)——解决控制台终端中文输出乱码
由于系统终端默认编码为GBK,所以需要修改为UTF-8 方法一 打开cmd输入chcp查看编码格式,查看以及修改如下图所示: 方法二