結果

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

ソースコード

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){
                Result = 0;
                System.out.println(Result);
                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