結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
55,636 KB
testcase_01 AC 131 ms
55,884 KB
testcase_02 AC 128 ms
55,776 KB
testcase_03 AC 130 ms
55,728 KB
testcase_04 AC 128 ms
55,688 KB
testcase_05 AC 129 ms
55,684 KB
testcase_06 AC 128 ms
55,436 KB
testcase_07 AC 129 ms
55,472 KB
testcase_08 AC 127 ms
55,568 KB
testcase_09 AC 127 ms
55,764 KB
testcase_10 AC 128 ms
55,436 KB
testcase_11 AC 128 ms
55,588 KB
testcase_12 AC 130 ms
55,752 KB
testcase_13 WA -
testcase_14 AC 130 ms
55,648 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
権限があれば一括ダウンロードができます

ソースコード

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