結果
問題 | No.264 じゃんけん |
ユーザー | yugi0922 |
提出日時 | 2020-06-24 08:37:57 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 116 ms / 5,000 ms |
コード長 | 1,770 bytes |
コンパイル時間 | 3,538 ms |
コンパイル使用メモリ | 74,460 KB |
実行使用メモリ | 55,936 KB |
最終ジャッジ日時 | 2023-09-16 20:53:49 |
合計ジャッジ時間 | 5,262 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 113 ms
55,880 KB |
testcase_01 | AC | 114 ms
55,584 KB |
testcase_02 | AC | 116 ms
55,592 KB |
testcase_03 | AC | 116 ms
55,528 KB |
testcase_04 | AC | 114 ms
55,376 KB |
testcase_05 | AC | 116 ms
55,936 KB |
testcase_06 | AC | 115 ms
55,628 KB |
testcase_07 | AC | 116 ms
55,736 KB |
testcase_08 | AC | 116 ms
55,440 KB |
ソースコード
import static java.lang.System.*; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.Scanner; public class JanKen_03 { static final int[] myvalidValues = {0,2}; static final int[] yourvalidValues = {0,2}; static final int GU = 0; static final int TYOKI = 0; static final int PA = 0; //勝敗 static final String KATI = "Won"; static final String MAKE = "Lost"; static final String AIKO = "Drew"; public static void main(String[] args) { Scanner sc = new Scanner(System.in); BufferedReader reader = new BufferedReader(new InputStreamReader(in)); int myHand = 0; int yourHand = 0; try{ String[] inputs = reader.readLine().split(" "); myHand = Integer.parseInt(inputs[0]); yourHand = Integer.parseInt(inputs[1]); if(validNum(myHand, yourHand, myvalidValues, yourvalidValues )){ System.out.println(janKen(myHand, yourHand)); } }catch(NumberFormatException ne){ System.out.println("1~2の数字を入力してください"); }catch(IOException io){ System.out.println("読込中にエラーが起きました"); }finally{ try{ reader.close(); }catch(IOException io){ System.out.println("BufferedReaderのクローズに失敗しました"); } } } static boolean validNum(int myHand,int yourHand,int[] myvalidValues,int[] yourvalidValues ){ boolean result = false; if(myHand >= myvalidValues[0] && myHand <= myvalidValues[1] && yourHand >= yourvalidValues[0] && yourHand <= yourvalidValues[1]){ return true; } return result; } static String janKen(int myHand,int yourHand){ switch(myHand - yourHand){ case -1: case 2 : return KATI; case 0 : return AIKO; default : return MAKE; } } }