結果

問題 No.593 4進FizzBuzz
ユーザー nanaenanae
提出日時 2017-11-10 22:53:36
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 70 ms / 2,000 ms
コード長 1,131 bytes
コンパイル時間 2,828 ms
コンパイル使用メモリ 152,432 KB
実行使用メモリ 9,156 KB
最終ジャッジ日時 2023-09-03 16:48:18
合計ジャッジ時間 7,572 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,384 KB
testcase_10 AC 1 ms
4,384 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 1 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 1 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 36 ms
7,496 KB
testcase_17 AC 35 ms
7,664 KB
testcase_18 AC 35 ms
7,748 KB
testcase_19 AC 69 ms
8,168 KB
testcase_20 AC 35 ms
7,156 KB
testcase_21 AC 34 ms
7,504 KB
testcase_22 AC 69 ms
9,156 KB
testcase_23 AC 35 ms
7,224 KB
testcase_24 AC 35 ms
8,736 KB
testcase_25 AC 34 ms
6,908 KB
testcase_26 AC 70 ms
7,420 KB
testcase_27 AC 70 ms
7,464 KB
testcase_28 AC 35 ms
7,184 KB
testcase_29 AC 69 ms
8,148 KB
testcase_30 AC 35 ms
7,184 KB
testcase_31 AC 34 ms
8,060 KB
testcase_32 AC 36 ms
7,188 KB
testcase_33 AC 70 ms
7,716 KB
testcase_34 AC 36 ms
7,716 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

void main() {
    char[] n;
    scan(n);

    reverse(n);

    int k = n.length.to!int;

    int m3, m5;

    foreach (i; 0 .. k) {
        (m3 += n[i] - '0') %= 3;

        if (i & 1) {
            (m5 += n[i] - '0') %= 5;
        }
        else {
            (m5 += (n[i] - '0') * 4) %= 5;
        }
    } 

    debug {
        writefln("m3:%d, m5:%d", m3, m5);
    }

    if (!m3 & !m5) {
        writeln("FizzBuzz");
    }
    else if (!m3) {
        writeln("Fizz");
    }
    else if (!m5) {
        writeln("Buzz");
    }
    else {
        writeln(n.retro());
    }
}





void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}
0