結果

問題 No.593 4進FizzBuzz
ユーザー nanaenanae
提出日時 2017-11-11 12:11:24
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 35 ms / 2,000 ms
コード長 1,593 bytes
コンパイル時間 935 ms
コンパイル使用メモリ 91,884 KB
実行使用メモリ 8,876 KB
最終ジャッジ日時 2023-09-03 16:51:19
合計ジャッジ時間 3,661 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 2 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,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,384 KB
testcase_16 AC 33 ms
6,728 KB
testcase_17 AC 34 ms
7,440 KB
testcase_18 AC 34 ms
6,964 KB
testcase_19 AC 35 ms
7,368 KB
testcase_20 AC 35 ms
6,564 KB
testcase_21 AC 34 ms
8,876 KB
testcase_22 AC 35 ms
7,056 KB
testcase_23 AC 34 ms
6,772 KB
testcase_24 AC 33 ms
7,252 KB
testcase_25 AC 33 ms
7,228 KB
testcase_26 AC 34 ms
7,220 KB
testcase_27 AC 35 ms
7,504 KB
testcase_28 AC 34 ms
6,480 KB
testcase_29 AC 34 ms
7,552 KB
testcase_30 AC 34 ms
6,760 KB
testcase_31 AC 33 ms
8,032 KB
testcase_32 AC 33 ms
8,052 KB
testcase_33 AC 34 ms
6,916 KB
testcase_34 AC 34 ms
7,500 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);

    int k = n.length.to!int;

    int m3, m5;

    foreach (i ; 0 .. k) {
        m3 = (m3 * 4 + (n[i] - '0')) % 3;
        m5 = (m5 * 4 + (n[i] - '0')) % 5;
    }

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



struct Stack(T) {
private:
    int N, peek;
    T[] data;

public:
    this(int size) 
    {
        N = size;
        data = new T[](N);
    }

    bool empty() @property
    {
        return peek == 0;
    }

    bool full() @property
    {
        return peek == N;
    }

    void push(T x) @property
    {
        assert(!full);
        data[peek++] = x;
    }

    void pop() @property
    {
        assert(!empty);
        --peek;
    }

    T top() @property
    {
        return data[peek - 1];
    }

    void clear() @property
    {
        peek = 0;
    }

    int length() @property
    {
        return peek;
    }

}




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