結果
| 問題 |
No.63 ポッキーゲーム
|
| コンテスト | |
| ユーザー |
SagToki
|
| 提出日時 | 2018-05-14 15:54:12 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,379 bytes |
| コンパイル時間 | 4,439 ms |
| コンパイル使用メモリ | 77,900 KB |
| 実行使用メモリ | 41,568 KB |
| 最終ジャッジ日時 | 2024-06-28 11:43:50 |
| 合計ジャッジ時間 | 8,593 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 14 WA * 8 |
ソースコード
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("想定外のエラーです");
}
}
}
SagToki