結果

問題 No.9002 FizzBuzz(テスト用)
ユーザー SaYaSaYa
提出日時 2015-11-03 21:26:49
言語 Java21
(openjdk 21)
結果
AC  
実行時間 137 ms / 5,000 ms
コード長 701 bytes
コンパイル時間 2,772 ms
コンパイル使用メモリ 76,072 KB
実行使用メモリ 56,104 KB
最終ジャッジ日時 2023-10-11 13:34:57
合計ジャッジ時間 3,986 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
55,756 KB
testcase_01 AC 130 ms
55,500 KB
testcase_02 AC 132 ms
54,332 KB
testcase_03 AC 137 ms
56,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();

        IntStream.rangeClosed(1, n).forEach(i -> {
            boolean isFizz = (i % 3 == 0);
            boolean isBuzz = (i % 5 == 0);
            if (isFizz) {
                System.out.print("Fizz");
            }
            if (isBuzz) {
                System.out.print("Buzz");
            }
            if (!isFizz & !isBuzz) {
                System.out.print(i);
            }
            if (i != n) {
                System.out.println();
            }
        });
    }
}
0