結果

問題 No.418 ミンミンゼミ
ユーザー nihi9119nihi9119
提出日時 2017-05-29 18:03:02
言語 Java21
(openjdk 21)
結果
AC  
実行時間 41 ms / 1,000 ms
コード長 1,799 bytes
コンパイル時間 3,328 ms
コンパイル使用メモリ 73,996 KB
実行使用メモリ 49,568 KB
最終ジャッジ日時 2023-09-23 01:52:21
合計ジャッジ時間 5,754 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
49,216 KB
testcase_01 AC 41 ms
49,452 KB
testcase_02 AC 40 ms
49,216 KB
testcase_03 AC 40 ms
49,212 KB
testcase_04 AC 40 ms
49,180 KB
testcase_05 AC 40 ms
49,232 KB
testcase_06 AC 40 ms
49,148 KB
testcase_07 AC 40 ms
49,328 KB
testcase_08 AC 40 ms
49,568 KB
testcase_09 AC 40 ms
49,064 KB
testcase_10 AC 40 ms
49,292 KB
testcase_11 AC 41 ms
49,300 KB
testcase_12 AC 40 ms
47,216 KB
testcase_13 AC 40 ms
49,184 KB
testcase_14 AC 41 ms
49,188 KB
testcase_15 AC 40 ms
47,508 KB
testcase_16 AC 40 ms
49,024 KB
testcase_17 AC 40 ms
49,192 KB
testcase_18 AC 40 ms
49,276 KB
testcase_19 AC 41 ms
49,304 KB
testcase_20 AC 40 ms
49,032 KB
testcase_21 AC 39 ms
49,272 KB
testcase_22 AC 40 ms
49,524 KB
testcase_23 AC 40 ms
49,332 KB
testcase_24 AC 41 ms
49,220 KB
testcase_25 AC 40 ms
49,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package test_5;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/*No.418 ミンミンゼミ
*
* - まず "mi" から始まる。
* - その後いくつかの "-" がつく。"-" の数は 0 でもかまわない。
* - 最後に "n" で終わる。
* あなたの仕事は, 文字列 SS がいくつのミーン文字列を繰り返しているかを数えることです。
* */

public class Question_05_0526_2 {

	static final int MIN_LENGTH = 3;
	static final int MAX_LENGTH = 100;
	static final String FIRST_CHARACTER = "mi";
	static final String LAST_CHARACTER = "n";

	public static void main(String[] args) {

		InputStreamReader re = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(re);

		try {

			int minCount = 0;
			int StringCount = 0;
			String twoCharacter;
			String minString = br.readLine();

			if (NumJudgment(minString)) {

				for (char c : minString.toCharArray()) {
					if (c == 'n') {
						minCount++;
					}
				}

				// セミが何回「ミーン」と鳴いたかを出力
				System.out.println(minCount);

			} else {
				System.out.println("桁数が不正です");
			}

		} catch (IOException e) {
			System.out.println("エラーが発生しました");
		} finally {
			try {
				re.close();
				br.close();
			} catch (IOException e) {
				System.out.println("InputStreamReader、BufferedReaderクローズ中にエラーが発生しました");
			}
		}
	}

	/**
	 * 有効値判定メソッド
	 *
	 * @param minString
	 * @return true:問題なし、false:エラー
	 */
	private static boolean NumJudgment(String minString) {
		Boolean result = false;
		if (MIN_LENGTH <= minString.length() && minString.length() <= MAX_LENGTH) {
			result = true;
		}
		return result;
	}

}
0