結果

問題 No.593 4進FizzBuzz
ユーザー YamaKasaYamaKasa
提出日時 2018-09-25 17:17:16
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 563 bytes
コンパイル時間 2,537 ms
コンパイル使用メモリ 74,872 KB
実行使用メモリ 63,628 KB
最終ジャッジ日時 2024-04-15 08:26:04
合計ジャッジ時間 13,540 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
54,196 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 131 ms
54,092 KB
testcase_04 AC 131 ms
53,852 KB
testcase_05 AC 133 ms
54,204 KB
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 355 ms
61,328 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 351 ms
61,316 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 AC 351 ms
61,208 KB
testcase_28 WA -
testcase_29 AC 365 ms
61,172 KB
testcase_30 WA -
testcase_31 AC 337 ms
61,216 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 AC 335 ms
61,400 KB
権限があれば一括ダウンロードができます

ソースコード

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