結果

問題 No.63 ポッキーゲーム
ユーザー SagTokiSagToki
提出日時 2018-05-14 16:01:48
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,279 bytes
コンパイル時間 3,492 ms
コンパイル使用メモリ 72,140 KB
実行使用メモリ 58,128 KB
最終ジャッジ日時 2023-09-10 20:38:08
合計ジャッジ時間 7,089 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,768 KB
testcase_01 AC 125 ms
55,512 KB
testcase_02 AC 126 ms
55,708 KB
testcase_03 WA -
testcase_04 AC 126 ms
54,124 KB
testcase_05 WA -
testcase_06 AC 126 ms
55,736 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 125 ms
55,776 KB
testcase_10 WA -
testcase_11 AC 125 ms
56,100 KB
testcase_12 AC 126 ms
55,968 KB
testcase_13 AC 124 ms
55,592 KB
testcase_14 AC 124 ms
55,580 KB
testcase_15 AC 126 ms
55,768 KB
testcase_16 AC 125 ms
55,576 KB
testcase_17 AC 125 ms
55,620 KB
testcase_18 AC 125 ms
55,800 KB
testcase_19 AC 128 ms
56,200 KB
testcase_20 AC 126 ms
55,888 KB
testcase_21 AC 126 ms
55,772 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;
                System.out.println(Result);
                System.exit(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