• 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);
        }
    }
    
  • 相关阅读:
    #ACsaber ——简单排序、字符串加空格、数组中的行 ~20.10.22
    #堆排序 20.09.27
    #并查集 20.09.25
    #卡特兰数 #抽屉原理 #Nim游戏 ——杂记
    #扩展欧几里得算法 ——线性同余方程 ~20.9.4
    #周测 7 —— 数的划分 、逆序对 、排座椅 、棋盘
    117. 占卜DIY
    116. 飞行员兄弟
    115.给树染色
    112.雷达设备
  • 原文地址:https://www.cnblogs.com/a1439775520/p/13076686.html
Copyright © 2020-2023  润新知