結果

問題 No.593 4進FizzBuzz
ユーザー nebukuro09nebukuro09
提出日時 2017-11-10 22:37:32
言語 D
(dmd 2.105.2)
結果
AC  
実行時間 26 ms / 2,000 ms
コード長 745 bytes
コンパイル時間 1,381 ms
コンパイル使用メモリ 93,900 KB
実行使用メモリ 6,796 KB
最終ジャッジ日時 2023-09-03 16:47:10
合計ジャッジ時間 4,058 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 2 ms
4,376 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,384 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 1 ms
4,384 KB
testcase_15 AC 1 ms
4,384 KB
testcase_16 AC 24 ms
6,240 KB
testcase_17 AC 24 ms
6,272 KB
testcase_18 AC 24 ms
6,324 KB
testcase_19 AC 24 ms
6,256 KB
testcase_20 AC 26 ms
6,296 KB
testcase_21 AC 24 ms
6,328 KB
testcase_22 AC 24 ms
6,276 KB
testcase_23 AC 23 ms
6,232 KB
testcase_24 AC 24 ms
6,392 KB
testcase_25 AC 25 ms
6,340 KB
testcase_26 AC 25 ms
6,344 KB
testcase_27 AC 25 ms
6,740 KB
testcase_28 AC 24 ms
6,276 KB
testcase_29 AC 25 ms
6,796 KB
testcase_30 AC 25 ms
6,300 KB
testcase_31 AC 24 ms
6,328 KB
testcase_32 AC 23 ms
6,300 KB
testcase_33 AC 24 ms
6,240 KB
testcase_34 AC 24 ms
6,340 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("Buzz");
    else
        writeln(S);
}
0