結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,436 KB
testcase_01 WA -
testcase_02 AC 128 ms
55,756 KB
testcase_03 WA -
testcase_04 AC 127 ms
55,668 KB
testcase_05 WA -
testcase_06 AC 127 ms
55,620 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 126 ms
55,748 KB
testcase_10 WA -
testcase_11 AC 129 ms
55,828 KB
testcase_12 AC 127 ms
55,808 KB
testcase_13 AC 127 ms
55,680 KB
testcase_14 AC 127 ms
55,780 KB
testcase_15 AC 126 ms
55,852 KB
testcase_16 AC 126 ms
55,676 KB
testcase_17 AC 126 ms
55,824 KB
testcase_18 AC 127 ms
55,860 KB
testcase_19 AC 126 ms
55,588 KB
testcase_20 AC 125 ms
55,684 KB
testcase_21 AC 126 ms
55,556 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) % 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