結果
| 問題 | No.8022 縛りFizzBuzz (Easy) |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-09-06 19:43:33 |
| 言語 | Java (openjdk 25.0.2) |
| 結果 |
AC
|
| 実行時間 | 59 ms / 2,000 ms |
| コード長 | 1,253 bytes |
| 記録 | |
| コンパイル時間 | 1,776 ms |
| コンパイル使用メモリ | 86,668 KB |
| 実行使用メモリ | 42,296 KB |
| 最終ジャッジ日時 | 2026-05-16 00:06:18 |
| 合計ジャッジ時間 | 2,885 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge2_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 4 |
ソースコード
import java.util.HashMap;
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int num = sc.nextInt();
HashMap<String, Integer> hashmap = storageNumber();
int three = hashmap.get("three");
int five = hashmap.get("five");
for (int i = hashmap.get("one"); i <= num; i++) {
if ((i % three == hashmap.get("zero")) && (i % five == hashmap.get("zero"))) {
System.out.println("FizzBuzz");
} else if (i % three == hashmap.get("zero")) {
System.out.println("Fizz");
} else if (i % five == hashmap.get("zero")) {
System.out.println("Buzz");
} else {
System.out.println(i);
}
}
sc.close();
}
static HashMap<String, Integer> storageNumber() {
HashMap<String, Integer> hashmap = new HashMap<>();
hashmap.put("zero", "".length());
hashmap.put("one", "l".length());
hashmap.put("two", "lZ".length());
hashmap.put("three", "lZE".length());
hashmap.put("four", "lZEA".length());
hashmap.put("five", "lZEAS".length());
hashmap.put("six", "lZEASb".length());
hashmap.put("seven", "lZEASbL".length());
hashmap.put("eight", "lZEASbLB".length());
hashmap.put("nine", "lZEASbLBq".length());
return hashmap;
}
}