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("想定外のエラーです"); } } }