結果

問題 No.473 和と積の和
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2017-03-15 15:39:26
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
MLE  
実行時間 -
コード長 1,048 bytes
コンパイル時間 1,817 ms
コンパイル使用メモリ 178,708 KB
実行使用メモリ 547,252 KB
最終ジャッジ日時 2023-09-17 01:50:18
合計ジャッジ時間 8,471 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
14,984 KB
testcase_01 AC 5 ms
10,600 KB
testcase_02 AC 5 ms
10,532 KB
testcase_03 AC 1,235 ms
161,844 KB
testcase_04 AC 5 ms
10,472 KB
testcase_05 AC 5 ms
10,496 KB
testcase_06 AC 5 ms
10,632 KB
testcase_07 AC 6 ms
10,540 KB
testcase_08 AC 5 ms
10,488 KB
testcase_09 AC 6 ms
10,532 KB
testcase_10 AC 5 ms
10,764 KB
testcase_11 AC 5 ms
10,780 KB
testcase_12 AC 5 ms
10,752 KB
testcase_13 AC 5 ms
10,604 KB
testcase_14 AC 5 ms
10,756 KB
testcase_15 AC 6 ms
10,632 KB
testcase_16 AC 6 ms
10,628 KB
testcase_17 AC 6 ms
10,796 KB
testcase_18 AC 5 ms
10,624 KB
testcase_19 AC 6 ms
10,596 KB
testcase_20 AC 6 ms
10,628 KB
testcase_21 AC 5 ms
10,760 KB
testcase_22 AC 6 ms
10,532 KB
testcase_23 AC 14 ms
12,632 KB
testcase_24 AC 20 ms
14,328 KB
testcase_25 MLE -
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 #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)




int N, X;
vector<int> d;
vector<int> enumdiv(int n) {
	vector<int> S;
	for (int i = 1; i*i <= n; i++) if (n%i == 0) { S.push_back(i); if (i*i != n) S.push_back(n / i); }
	sort(S.begin(), S.end());
	return S;
}
//-----------------------------------------------------------------
map<int,int> memo[1520][101];
int f(int n, int m, int k) { // d[m]以上の数をk個使って、積をnとする組合せ
	if (k == 0 && n == 0) return 1;
	if (k == 0) return 0;
	if (n == 0) return 0;
	if (m == d.size()) return 0;

	if (memo[m][k].count(n)) return memo[m][k][n];

	int ret = f(n, m + 1, k);
	int x = d[n], kk = k;
	while (x % d[m] == 0) {
		x /= d[m];
		kk--;
		int nn = lower_bound(d.begin(), d.end(), x) - d.begin();
		ret += f(nn, m + 1, kk);
		if (kk == 0) break;
	}

	return memo[m][k][n] = ret;
}
//-----------------------------------------------------------------
int main() {
	cin >> N >> X;

	d = enumdiv(X + 1);
	cout << f(d.size() - 1, 1, N) << endl;
}
0