結果

問題 No.3022 縛りFizzBuzz (Easy)
ユーザー neko_the_shadowneko_the_shadow
提出日時 2019-02-07 23:52:38
言語 Java21
(openjdk 21)
結果
AC  
実行時間 132 ms / 2,000 ms
コード長 700 bytes
コンパイル時間 2,964 ms
コンパイル使用メモリ 84,416 KB
実行使用メモリ 56,120 KB
最終ジャッジ日時 2023-09-08 15:01:18
合計ジャッジ時間 3,816 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

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

public class Main {
    static int zero  = 'a' - 'a';
    static int one   = 'b' - 'a';
    static int three = 'd' - 'a';
    static int five  = 'f' - 'a';
    
    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        int n = stdin.nextInt();
       IntStream.rangeClosed(one, n).mapToObj(Main::fizzbuzz).forEach(System.out::println);
    }
    
    public static String fizzbuzz(int i) {
        if (i % three == zero && i % five == zero)  return "FizzBuzz";
        if (i % three == zero)  return "Fizz";
        if (i % five == zero)  return "Buzz";
        return String.valueOf(i);
    }
}
0