結果

問題 No.593 4進FizzBuzz
ユーザー YamaKasaYamaKasa
提出日時 2018-09-25 17:19:51
言語 Java
(openjdk 23)
結果
AC  
実行時間 300 ms / 2,000 ms
コード長 560 bytes
コンパイル時間 2,277 ms
コンパイル使用メモリ 75,544 KB
実行使用メモリ 50,116 KB
最終ジャッジ日時 2024-10-05 00:55:17
合計ジャッジ時間 10,871 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 31
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String N = scan.next();
		scan.close();
		int k1 = 0;
		int k2 = 0;
		for(int i = 0; i < N.length(); i++) {
			int t = (int)(N.charAt(i) - '0') ;
			k1 = (4 * k1 + t) % 3;
			k2 = (4 * k2 + t) % 5;
		}
		if(k1 % 3 == 0) {
			if(k2 % 5 == 0) {
				System.out.println("FizzBuzz");
			}else {
				System.out.println("Fizz");
			}
		}else if(k2 % 5 == 0) {
			System.out.println("Buzz");
		}else {
			System.out.println(N);
		}
	}
}
0