結果

問題 No.112 ややこしい鶴亀算
ユーザー imcgskn
提出日時 2017-12-12 18:38:48
言語 Java
(openjdk 23)
結果
WA  
実行時間 -
コード長 771 bytes
コンパイル時間 3,563 ms
コンパイル使用メモリ 75,976 KB
実行使用メモリ 55,204 KB
最終ジャッジ日時 2024-12-14 06:14:02
合計ジャッジ時間 8,901 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 9 WA * 14
権限があれば一括ダウンロードができます

ソースコード

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