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 = []() ...
随机推荐
- HDU 2011 (水)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2011 题目大意:给你 m 个数,对于每个数,求前 n 项和,数列:1 - 1/2 + 1/3 - 1/ ...
- Linux相关命令、虚拟机网络配置
虚拟机联网 Linux命令 1.查找 #查找django进程,不包括grep自建的 ps -ef |grep django | grep -v grep # find 查找home目录下的name.t ...
- ubuntu下图形程序自启动的几种方法
版权声明:本文为本文为博主原创文章,转载请注明出处.如有问题,欢迎指正.博客地址:https://www.cnblogs.com/wsg1100/ @ 目录 0.前言 1.带桌面环境的自动启动 1.1 ...
- 如何在Unity中画抛物线
using UnityEngine; using System.Collections; using System.Collections.Generic; [ExecuteInEditMode] p ...
- 14.4 Go Xorm
14.4 Go Xorm 获取xorm go get -u -v github.com/go-xorm/xorm xorm增删改查 /** * 应用程序 * 同目录下多文件引用的问题解决方法: * h ...
- Django之JSON数据格式
JSON简介: o JSON 指的是 JavaScript 对象表示法(JavaScript Object Notation) o JSON 是轻量级的文本数据交换格式 o JSON ...
- PL/SQL语言语法
一.前言 SQL全称是"结构化查询语言(Structured Query Language)",而PL/SQL是过程语言(Procedure Language),是对SQL的扩展. ...
- IDEA三种注释详解
三种注释方式 行注释.块注释.方法或类说明注释. 一.快捷键:Ctrl + / 使用Ctrl+ /, 添加行注释,再次使用,去掉行注释 二.演示代码 if (hallSites != null &am ...
- Hyperledger Fabric——balance transfer(一)启动示例
Blacne transfer是Hyperledger fabric Node SDK的一个示例应用,主要使用了SDK中fabric-client 和 fabric-ca-client 模块中的API ...
- Java——java.lang.NullPointerException
JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); StandardJavaFileManager fileManager = ...