結果

問題 No.473 和と積の和
ユーザー nebukuro09nebukuro09
提出日時 2017-05-11 13:56:55
言語 D
(dmd 2.106.1)
結果
TLE  
(最新)
AC  
(最初)
実行時間 -
コード長 814 bytes
コンパイル時間 912 ms
コンパイル使用メモリ 103,388 KB
実行使用メモリ 61,072 KB
最終ジャッジ日時 2023-09-03 13:17:54
合計ジャッジ時間 7,136 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
61,072 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 1 ms
4,380 KB
testcase_03 AC 970 ms
19,624 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 2 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,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,380 KB
testcase_21 AC 2 ms
4,380 KB
testcase_22 AC 1 ms
4,384 KB
testcase_23 AC 8 ms
4,380 KB
testcase_24 AC 13 ms
4,380 KB
testcase_25 TLE -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
権限があれば一括ダウンロードができます

ソースコード

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[3]] mem;
    
    int dfs(int x, int k, int d) {
        if (d == N) return x == 1;
        int[3] key = [x, k, d];
        if (key in mem) return mem[key];
        
        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[key] = ans;
    }

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