結果

問題 No.3022 縛りFizzBuzz (Easy)
ユーザー yagi2yagi2
提出日時 2017-04-25 17:48:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 953 bytes
コンパイル時間 2,161 ms
コンパイル使用メモリ 73,248 KB
実行使用メモリ 56,260 KB
最終ジャッジ日時 2023-10-11 09:50:33
合計ジャッジ時間 3,737 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
56,044 KB
testcase_01 AC 118 ms
56,012 KB
testcase_02 AC 121 ms
55,968 KB
testcase_03 AC 125 ms
56,260 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = Integer.parseInt(sc.next());

        List<String> num = new ArrayList<>();

        num.add("zero");
        num.add("one");
        num.add("two");
        num.add("three");
        num.add("four");
        num.add("five");

        for (int i = num.indexOf("one"); i <= N; i++) {
            if (i % (num.indexOf("three") * num.indexOf("five")) == num.indexOf("zero")) {
                System.out.println("FizzBuzz");
            } else if (i % num.indexOf("three") == num.indexOf("zero")) {
                System.out.println("Fizz");
            } else if (i % num.indexOf("five") == num.indexOf("zero")) {
                System.out.println("Buzz");
            } else {
                System.out.println(i);
            }
        }
    }
}
0