結果
問題 | No.112 ややこしい鶴亀算 |
ユーザー |
|
提出日時 | 2017-06-08 18:53:44 |
言語 | Java21 (openjdk 21) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,971 bytes |
コンパイル時間 | 4,265 ms |
コンパイル使用メモリ | 81,764 KB |
実行使用メモリ | 54,912 KB |
最終ジャッジ日時 | 2024-09-22 13:34:30 |
合計ジャッジ時間 | 6,466 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 91 ms
52,580 KB |
testcase_01 | AC | 80 ms
51,144 KB |
testcase_02 | AC | 81 ms
51,088 KB |
testcase_03 | AC | 80 ms
50,932 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 79 ms
51,196 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 84 ms
51,192 KB |
testcase_11 | AC | 82 ms
51,156 KB |
testcase_12 | AC | 82 ms
51,052 KB |
testcase_13 | WA | - |
testcase_14 | AC | 81 ms
51,268 KB |
testcase_15 | WA | - |
testcase_16 | AC | 82 ms
51,124 KB |
testcase_17 | WA | - |
testcase_18 | AC | 79 ms
51,368 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | AC | 80 ms
51,348 KB |
testcase_22 | AC | 84 ms
51,304 KB |
testcase_23 | AC | 79 ms
50,984 KB |
testcase_24 | WA | - |
ソースコード
package test_5; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; /** * No.112 ややこしい鶴亀算 http://yukicoder.me/problems/no/112 * N 匹の動物がいる。 * 動物たちは 1 から N まで番号が振られている。 * また、動物たちはそれぞれ鶴か亀のいずれかである。 * ご存知の通り、鶴の足は 2 本、亀の足は 4 本である。 */ public class Question_15_0608_2 { static final int MIN = 2; static final int MAX = 50; public static void main(String[] args) { InputStreamReader re = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(re); try { int animalCount = Integer.parseInt(br.readLine()); String[] legStrList = br.readLine().split(" "); //有効値判定 if (NumJudg(animalCount, MIN, MAX)) { int Crane = 0; int turtle = 0; //足から求める for (int i = 0; i < legStrList.length; i++) { int num = Integer.parseInt(legStrList[i]); if (num % 4 == 0) { Crane++; } else { turtle++; } } System.out.println(Crane + " " + turtle); } else { System.out.println("入力値が有効範囲外です"); } } catch (NumberFormatException e) { System.out.println("数字を入力して下さい。"); } catch (IOException e) { System.out.println("エラーが発生しました。"); } finally { try { re.close(); br.close(); } catch (IOException e) { System.out.println("InputStreamReader、BufferedReaderクローズ中にエラーが発生しました"); } } } /** * 有効値判定 * @param input 判定するもの * @param max 最大値 * @param min 最小値 * @return 範囲内ならtrue,範囲外ならfalseを返す */ private static boolean NumJudg(int input, int min, int max) { Boolean result = false; if (min <= input && input <= max) { result = true; } return result; } }