結果

問題 No.63 ポッキーゲーム
ユーザー SagTokiSagToki
提出日時 2018-05-14 16:57:22
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,275 bytes
コンパイル時間 4,114 ms
コンパイル使用メモリ 72,528 KB
実行使用メモリ 55,972 KB
最終ジャッジ日時 2023-09-10 20:39:47
合計ジャッジ時間 7,030 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 121 ms
55,452 KB
testcase_02 WA -
testcase_03 AC 121 ms
55,392 KB
testcase_04 AC 122 ms
55,648 KB
testcase_05 AC 120 ms
55,972 KB
testcase_06 AC 121 ms
55,724 KB
testcase_07 AC 119 ms
55,688 KB
testcase_08 AC 120 ms
55,388 KB
testcase_09 WA -
testcase_10 AC 120 ms
55,768 KB
testcase_11 WA -
testcase_12 AC 121 ms
55,712 KB
testcase_13 AC 121 ms
55,620 KB
testcase_14 AC 119 ms
55,620 KB
testcase_15 AC 122 ms
55,768 KB
testcase_16 AC 121 ms
55,796 KB
testcase_17 AC 121 ms
55,648 KB
testcase_18 AC 122 ms
55,408 KB
testcase_19 AC 122 ms
55,936 KB
testcase_20 AC 122 ms
55,720 KB
testcase_21 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Re_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 == 0){
                Result = L / 2 - K;
            }else{
                Result = (int) Math.floor(L / (2 * K));
                Result *= K;
            }
            
            System.out.println(Result);
    
        }catch(InputMismatchException e){
            System.out.println("数値を入力してください");
        }catch(Exception E){
            System.out.println("想定外のエラーです");
        }
    } 
}
0