結果

問題 No.639 An Ordinary Sequence
コンテスト
ユーザー fushime2
提出日時 2018-04-11 19:40:58
言語 D
(dmd 2.112.0)
コンパイル:
dmd -fPIE -m64 -w -wi -O -release -inline -I/opt/dmd/src/druntime/import/ -I/opt/dmd/src/phobos -L-L/opt/dmd/linux/lib64/ -fPIC _filename_
実行:
./Main
結果
WA  
実行時間 -
コード長 527 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 3,065 ms
コンパイル使用メモリ 347,164 KB
実行使用メモリ 7,720 KB
最終ジャッジ日時 2026-03-05 19:55:24
合計ジャッジ時間 4,005 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample WA * 2
other WA * 17
権限があれば一括ダウンロードができます
コンパイルメッセージ
/home/linuxbrew/.linuxbrew/opt/dmd/include/dlang/dmd/core/checkedint.d(814): Warning: cannot inline function `core.checkedint.mulu!().mulu`
ulong mulu()(ulong x, uint y, ref bool overflow)
      ^

ソースコード

diff #
raw source code

import std.stdio, std.algorithm, std.string, std.conv, std.array, std.range, std.math;

static immutable int N = 500000;

long[] precalc() {
    long[] d = new long[N];
    d[0] = 1;
    foreach (i; 1..N) d[i] = d[i/3] + d[i/5];
    return d;
}

void main() {
    static long[] dp = precalc();
    writeln(dp[33]);
    long n;
    readf("%d\n", &n);

    long f(long x) {
        if (x < N)
            return dp[x.to!int];
        return x == 0 ? 1L : f(x/3) + f(x/5);
    }

    writeln(f(n));
    auto _ = readln(); // dbg
}
0