結果

問題 No.593 4進FizzBuzz
ユーザー nebukuro09nebukuro09
提出日時 2017-11-10 22:30:25
言語 D
(dmd 2.106.1)
結果
WA  
実行時間 -
コード長 749 bytes
コンパイル時間 2,664 ms
コンパイル使用メモリ 94,016 KB
実行使用メモリ 7,040 KB
最終ジャッジ日時 2023-09-03 16:46:41
合計ジャッジ時間 5,557 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 WA -
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,384 KB
testcase_08 WA -
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 ms
4,384 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 2 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 WA -
testcase_16 AC 24 ms
6,552 KB
testcase_17 WA -
testcase_18 AC 24 ms
6,368 KB
testcase_19 AC 26 ms
6,248 KB
testcase_20 AC 26 ms
6,364 KB
testcase_21 AC 25 ms
6,248 KB
testcase_22 AC 26 ms
6,256 KB
testcase_23 AC 25 ms
6,316 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 25 ms
6,248 KB
testcase_27 AC 26 ms
6,308 KB
testcase_28 AC 25 ms
6,328 KB
testcase_29 AC 26 ms
6,248 KB
testcase_30 AC 25 ms
6,320 KB
testcase_31 AC 25 ms
6,244 KB
testcase_32 WA -
testcase_33 AC 25 ms
6,296 KB
testcase_34 AC 26 ms
6,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop;


void main() {
    auto S = readln.chomp;
    auto N = S.length.to!int;

    int three = 0;
    int five = 0;
    int p3 = 1;
    int p5 = 1;

    foreach (i; iota(N-1, -1, -1)) {
        int x3 = (S[i] - '0') * p3;
        (three += x3 % 3) %= 3;
        p3 = p3 * 4 % 3;

        int x5 = (S[i] - '0') * p5;
        (five += x5 % 5) %= 5;
        p5 = p5 * 4 % 5;
    }

    if (three == 0 && five == 0)
        writeln("FizzBuzz");
    else if (three == 0)
        writeln("Fizz");
    else if (five == 0)
        writeln("FizzBuzz");
    else
        writeln(S);
}
0