結果

問題 No.8022 縛りFizzBuzz (Easy)
コンテスト
ユーザー マサ
提出日時 2022-09-06 19:43:33
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 59 ms / 2,000 ms
コード長 1,253 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 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
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

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;
	}
}
0