結果

問題 No.473 和と積の和
ユーザー nebukuro09nebukuro09
提出日時 2017-05-11 13:51:30
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 2,737 ms / 3,000 ms
コード長 828 bytes
コンパイル時間 4,396 ms
コンパイル使用メモリ 98,356 KB
実行使用メモリ 49,304 KB
最終ジャッジ日時 2023-09-03 13:17:30
合計ジャッジ時間 18,060 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 572 ms
22,724 KB
testcase_04 AC 1 ms
4,380 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 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 2 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 1 ms
4,376 KB
testcase_18 AC 2 ms
4,380 KB
testcase_19 AC 2 ms
4,380 KB
testcase_20 AC 2 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 1 ms
4,380 KB
testcase_23 AC 5 ms
4,380 KB
testcase_24 AC 7 ms
4,384 KB
testcase_25 AC 2,737 ms
49,304 KB
testcase_26 AC 384 ms
17,988 KB
testcase_27 AC 574 ms
20,300 KB
testcase_28 AC 1 ms
4,380 KB
testcase_29 AC 3 ms
4,376 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 2 ms
4,376 KB
testcase_32 AC 2 ms
4,380 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 1,562 ms
37,040 KB
testcase_35 AC 1,551 ms
37,240 KB
testcase_36 AC 4 ms
4,384 KB
testcase_37 AC 2 ms
4,376 KB
testcase_38 AC 1,519 ms
33,188 KB
testcase_39 AC 800 ms
22,404 KB
testcase_40 AC 836 ms
26,764 KB
testcase_41 AC 918 ms
27,812 KB
testcase_42 AC 7 ms
4,380 KB
testcase_43 AC 163 ms
19,240 KB
testcase_44 AC 519 ms
28,856 KB
testcase_45 AC 2 ms
4,380 KB
testcase_46 AC 1 ms
4,380 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.split.map!(to!int);
    auto N = s[0];
    auto X = s[1] + 1;
    
    int[] factors;

    for (int i = 2; i * i <= X; i++) {
        if (X % i == 0) factors ~= (i * i == X ? [i] : [i, X / i]);
    }


    int[int][int][int] mem;
    
    int dfs(int x, int k, int d) {
        if (d == N) return x == 1;
        if (x in mem && k in mem[x] && d in mem[x][k]) return mem[x][k][d];
        
        int ans = 0;
        foreach (i; k..factors.length.to!int) {
            if (x % factors[i] == 0) ans += dfs(x / factors[i], i, d+1);
        }

        return mem[x][k][d] = ans;
    }

    dfs(X, 0, 0).writeln;
}
0