結果

問題 No.9002 FizzBuzz(テスト用)
ユーザー mochi8kmochi8k
提出日時 2016-03-20 10:31:46
言語 Java21
(openjdk 21)
結果
AC  
実行時間 148 ms / 5,000 ms
コード長 473 bytes
コンパイル時間 4,100 ms
コンパイル使用メモリ 85,468 KB
実行使用メモリ 57,832 KB
最終ジャッジ日時 2024-04-08 17:15:06
合計ジャッジ時間 4,943 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 138 ms
57,832 KB
testcase_01 AC 146 ms
57,680 KB
testcase_02 AC 147 ms
57,648 KB
testcase_03 AC 148 ms
57,648 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class FizzBuzz {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		if (sc.hasNextInt()) {
			int inputNumber = sc.nextInt();
			for (int i = 1; i <= inputNumber; ++i) {
				String word = "";
				if (i % 3 == 0) {
					word += "Fizz";
				}

				if (i % 5 == 0) {
					word += "Buzz";
				}

				if (word == "") {
					System.out.println(i);
				} else {
					System.out.println(word);
				}
			}
		}
	}

}
0