結果

問題 No.264 じゃんけん
ユーザー velfare_nagatavelfare_nagata
提出日時 2016-10-04 18:21:46
言語 Java21
(openjdk 21)
結果
AC  
実行時間 128 ms / 5,000 ms
コード長 1,506 bytes
コンパイル時間 3,598 ms
コンパイル使用メモリ 74,508 KB
実行使用メモリ 57,704 KB
最終ジャッジ日時 2023-08-13 21:52:40
合計ジャッジ時間 5,653 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,404 KB
testcase_01 AC 128 ms
55,652 KB
testcase_02 AC 124 ms
55,836 KB
testcase_03 AC 127 ms
55,744 KB
testcase_04 AC 125 ms
55,920 KB
testcase_05 AC 123 ms
57,704 KB
testcase_06 AC 124 ms
55,596 KB
testcase_07 AC 125 ms
56,228 KB
testcase_08 AC 124 ms
55,916 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder;

import java.util.Hashtable;
import java.util.Scanner;

public class Answer {
	/**
	 * 自分と相手がじゃんけんをする。
	 * じゃんけんの結果を標準出力に出力してください。
	 * 結果は、自分が勝ったら「Won」、自分が負けたら「Lost」、引き分けなら「Drew」を出力してください。
	 * ぐー, ちょき, ぱーをそれぞれ 0, 1, 2とし、1つ目に自分のが2つ目に相手のが与えられます。
	 */
	public static void main(String[] args) {
        // パラメータ取得
        Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		sc.close();

        // じゃんけんの手をそれぞれ下記の通りに管理
        // グー:1、チョキ:2、パー:4
        int[] rpsData = new int[3];
        rpsData[0] = 1;
        rpsData[1] = 2;
        rpsData[2] = 4;

        // 2人でじゃんけんをした場合の勝者の組み合わせを下記の通りに管理
        // キーがない組み合わせはあいこ
        Hashtable<Integer, Integer> rpsWinTable = new Hashtable<Integer, Integer>();
        rpsWinTable.put(1 | 2, 1);
        rpsWinTable.put(2 | 4, 2);
        rpsWinTable.put(4 | 1, 4);

        if(!rpsWinTable.containsKey(rpsData[n] | rpsData[k])){
        	System.out.println( "Drew");
        }else {
            System.out.println( (rpsWinTable.get(rpsData[n] | rpsData[k]) == rpsData[n]) ? "Won" : "Lost");
        }
	}
}
0