結果

問題 No.112 ややこしい鶴亀算
ユーザー imcgsknimcgskn
提出日時 2017-12-12 18:38:48
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 771 bytes
コンパイル時間 3,962 ms
コンパイル使用メモリ 76,096 KB
実行使用メモリ 56,972 KB
最終ジャッジ日時 2024-05-08 05:06:57
合計ジャッジ時間 9,101 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 160 ms
42,324 KB
testcase_01 AC 161 ms
42,144 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 160 ms
42,424 KB
testcase_05 AC 164 ms
42,288 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 158 ms
42,180 KB
testcase_09 AC 164 ms
42,412 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 147 ms
41,780 KB
testcase_14 AC 168 ms
42,636 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 166 ms
42,536 KB
testcase_20 AC 168 ms
42,436 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 166 ms
42,540 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Tsurukame {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);

        int num = stdIn.nextInt(); //匹数

        int tsuru = 0; //鶴
        int kame = 0; //亀

        final int tlegs = 2;
        final int klegs = 4;

        for(int i = 0; i < num; i++){
            int legs = stdIn.nextInt(); //足の本数(2or4)
            if(legs / (num - 1) == tlegs){
                tsuru++;
            }
            else if(legs / (num - 1) == klegs){
                kame++;
            }
            else{
                System.out.println("足の数は正しい値(2 or 4)を入力してください");
            }
        }
        System.out.println(tsuru + " " + kame);
    }
}
0