結果
問題 | No.9002 FizzBuzz(テスト用) |
ユーザー | oyafuso |
提出日時 | 2019-03-11 10:23:44 |
言語 | Java21 (openjdk 21) |
結果 |
AC
|
実行時間 | 128 ms / 5,000 ms |
コード長 | 867 bytes |
コンパイル時間 | 2,027 ms |
コンパイル使用メモリ | 71,612 KB |
実行使用メモリ | 56,108 KB |
最終ジャッジ日時 | 2023-09-05 20:02:07 |
合計ジャッジ時間 | 3,141 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 119 ms
56,108 KB |
testcase_01 | AC | 121 ms
55,768 KB |
testcase_02 | AC | 127 ms
55,584 KB |
testcase_03 | AC | 128 ms
55,920 KB |
ソースコード
import java.util.*; class Main { private static final String SPLIT_STR = " "; private static final String STR_CASE_3 = "Fizz"; private static final String STR_CASE_5 = "Buzz"; public static void main(String[] args) { // Scanner生成 Scanner sc = new Scanner(System.in); // 入力設定 String input = sc.nextLine(); int num = Integer.parseInt(input); // Scannerクローズ sc.close(); // ループ処理 for (int i = 1; i <= num; i++) { // 変数設定 String result = ""; int remain3 = i % 3; int remain5 = i % 5; // メイン処理 if (remain3 == 0 && remain5 == 0) { result = STR_CASE_3 + STR_CASE_5; } else if (remain3 == 0) { result = STR_CASE_3; } else if (remain5 == 0) { result = STR_CASE_5; } else { result = String.valueOf(i); } // 出力 System.out.println(result); } } }