/+ dub.sdl: name "A" dependency "dcomp" version=">=0.0.2" +/ import std.stdio, std.conv, std.algorithm; // import dcomp.scanner; Scanner sc; static this() {sc = new Scanner();} int[] divlist; int[int[3]] dp; int calc(int N, int X, int B) { if (N == 0) { if (X == 1) return 1; return 0; } int[3] key = [N, X, B]; if (key in dp) { return dp[key]; } int ans = 0; foreach (d; divlist) { if (d < B) continue; if (X < d) break; if (X % d) continue; ans += calc(N-1, X/d, d); } return dp[key] = ans; } int main() { int N, X; sc.read(N, X); X++; for (int i = 1; i*i <= X; i++) { if (X % i == 0) { divlist ~= i; if (i*i != X) divlist ~= X/i; } } sort(divlist); writeln(calc(N, X, 2)); return 0; } /* IMPORT /Users/yosupo/Program/dcomp/source/dcomp/scanner.d */ // module dcomp.scanner; class Scanner { import std.stdio : File, readln, stdin; import std.conv : to; import std.range : front, popFront, array, ElementType; import std.array : split; import std.traits : isSomeString, isDynamicArray; import std.algorithm : map; File f; this(File f = stdin) { this.f = f; } string[] buf; bool succ() { while (!buf.length) { if (f.eof) return false; buf = readln.split; } return true; } int read(Args...)(auto ref Args args) { foreach (i, ref v; args) { if (!succ()) return i; alias VT = typeof(v); static if (!isSomeString!VT && isDynamicArray!VT) { v = buf.map!(to!(ElementType!VT)).array; buf.length = 0; } else { v = buf.front.to!VT; buf.popFront(); } } return args.length; } }