結果

問題 No.63 ポッキーゲーム
ユーザー SagToki
提出日時 2018-05-14 16:57:22
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 1,275 bytes
コンパイル時間 3,907 ms
コンパイル使用メモリ 78,964 KB
実行使用メモリ 54,568 KB
最終ジャッジ日時 2024-06-28 11:46:03
合計ジャッジ時間 7,866 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 17 WA * 5
権限があれば一括ダウンロードができます

ソースコード

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