結果
| 問題 |
No.473 和と積の和
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-05-11 13:56:55 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
TLE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 814 bytes |
| コンパイル時間 | 807 ms |
| コンパイル使用メモリ | 116,068 KB |
| 実行使用メモリ | 17,556 KB |
| 最終ジャッジ日時 | 2024-06-12 19:09:54 |
| 合計ジャッジ時間 | 6,689 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 21 TLE * 1 -- * 21 |
ソースコード
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;
}