結果

問題 No.63 ポッキーゲーム
ユーザー SagTokiSagToki
提出日時 2018-05-14 17:41:14
言語 Java21
(openjdk 21)
結果
AC  
実行時間 124 ms / 5,000 ms
コード長 1,161 bytes
コンパイル時間 3,551 ms
コンパイル使用メモリ 72,968 KB
実行使用メモリ 56,060 KB
最終ジャッジ日時 2023-09-10 20:40:56
合計ジャッジ時間 7,026 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 120 ms
55,660 KB
testcase_01 AC 121 ms
55,716 KB
testcase_02 AC 122 ms
55,860 KB
testcase_03 AC 120 ms
55,832 KB
testcase_04 AC 120 ms
55,828 KB
testcase_05 AC 120 ms
55,696 KB
testcase_06 AC 122 ms
55,716 KB
testcase_07 AC 120 ms
55,720 KB
testcase_08 AC 119 ms
55,536 KB
testcase_09 AC 120 ms
55,712 KB
testcase_10 AC 122 ms
53,992 KB
testcase_11 AC 121 ms
55,520 KB
testcase_12 AC 121 ms
55,880 KB
testcase_13 AC 122 ms
55,980 KB
testcase_14 AC 122 ms
55,704 KB
testcase_15 AC 124 ms
55,752 KB
testcase_16 AC 121 ms
55,460 KB
testcase_17 AC 122 ms
56,060 KB
testcase_18 AC 121 ms
55,840 KB
testcase_19 AC 122 ms
55,512 KB
testcase_20 AC 122 ms
55,456 KB
testcase_21 AC 122 ms
55,932 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();
            double 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);
            }
            //Result = Math.ceil( L / (K * 2) ) - 1 ;
            Result = (K * 2);
            Result = L / Result;
            Result = Math.ceil(Result);
            Result --;
            Result *= K ;
            
            System.out.println((int)Result);
    
        }catch(InputMismatchException e){
            System.out.println("数値を入力してください");
        }catch(Exception E){
            System.out.println("想定外のエラーです");
        }
    } 
}
0