結果

問題 No.112 ややこしい鶴亀算
ユーザー imcgsknimcgskn
提出日時 2017-12-12 18:41:36
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 640 bytes
コンパイル時間 3,499 ms
コンパイル使用メモリ 76,224 KB
実行使用メモリ 57,124 KB
最終ジャッジ日時 2024-05-08 05:07:41
合計ジャッジ時間 7,328 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 137 ms
54,796 KB
testcase_01 AC 142 ms
57,000 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 AC 142 ms
55,064 KB
testcase_05 AC 133 ms
54,912 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 148 ms
55,176 KB
testcase_09 AC 126 ms
53,632 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 141 ms
55,180 KB
testcase_14 AC 130 ms
54,408 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 142 ms
54,832 KB
testcase_20 AC 142 ms
54,596 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 AC 159 ms
54,988 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++;
            }
        }
        System.out.println(tsuru + " " + kame);
    }
}
0