結果
| 問題 |
No.8022 縛りFizzBuzz (Easy)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2022-09-06 19:39:35 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,194 bytes |
| コンパイル時間 | 4,369 ms |
| コンパイル使用メモリ | 78,720 KB |
| 実行使用メモリ | 54,628 KB |
| 最終ジャッジ日時 | 2024-11-21 20:11:59 |
| 合計ジャッジ時間 | 4,857 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | WA * 4 |
ソースコード
import java.util.HashMap;
import java.util.Scanner;
public class DifficultFizzBuzz {
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 == 0) && (i % five == 0)) {
System.out.println("FizzBuzz");
} else if (i % three == 0) {
System.out.println("Fizz");
} else if (i % five == 0) {
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;
}
}