結果

問題 No.63 ポッキーゲーム
ユーザー SagTokiSagToki
提出日時 2018-05-14 15:58:32
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,204 bytes
コンパイル時間 4,447 ms
コンパイル使用メモリ 72,288 KB
実行使用メモリ 56,568 KB
最終ジャッジ日時 2023-09-10 20:37:54
合計ジャッジ時間 7,104 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
55,748 KB
testcase_01 WA -
testcase_02 AC 124 ms
56,104 KB
testcase_03 WA -
testcase_04 AC 123 ms
55,788 KB
testcase_05 WA -
testcase_06 AC 122 ms
55,744 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 122 ms
55,868 KB
testcase_10 WA -
testcase_11 AC 122 ms
56,072 KB
testcase_12 AC 122 ms
55,780 KB
testcase_13 AC 123 ms
55,864 KB
testcase_14 AC 122 ms
55,588 KB
testcase_15 AC 121 ms
55,764 KB
testcase_16 AC 122 ms
55,588 KB
testcase_17 AC 120 ms
56,164 KB
testcase_18 AC 120 ms
56,012 KB
testcase_19 AC 121 ms
56,184 KB
testcase_20 AC 121 ms
55,532 KB
testcase_21 AC 119 ms
55,664 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.InputMismatchException;

public class PockyGame {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        try{
            int L = scanner.nextInt();
            int K = scanner.nextInt();
            int Result = 0;
            
            
            if(L < 1 || L > Math.pow(10,9)){
                System.out.println("Lは1から1000000000の範囲で入力してください");
                System.exit(0);
            }
            if(K < 1 || K > 50){
                System.out.println("Kは1から50の範囲で入力してください");
                System.exit(0);
            }
            if(L < K){
                Result = 0;
            }
            if((L / K) % 2 == 0){
                Result = L / 2 - K;
            }else{
                Result = L / (2 * K);
                Result *= K;
            }
            
            System.out.println(Result);
    
        }catch(InputMismatchException e){
            System.out.println("数値を入力してください");
        }catch(Exception E){
            System.out.println("想定外のエラーです");
        }
    } 
}
0