結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
10,544 KB
testcase_01 AC 5 ms
10,564 KB
testcase_02 AC 5 ms
10,552 KB
testcase_03 AC 1,175 ms
161,860 KB
testcase_04 AC 5 ms
10,560 KB
testcase_05 AC 5 ms
10,736 KB
testcase_06 AC 5 ms
10,552 KB
testcase_07 AC 6 ms
10,540 KB
testcase_08 AC 5 ms
10,540 KB
testcase_09 AC 6 ms
10,536 KB
testcase_10 AC 5 ms
10,732 KB
testcase_11 AC 5 ms
10,832 KB
testcase_12 AC 6 ms
10,632 KB
testcase_13 AC 6 ms
10,600 KB
testcase_14 AC 6 ms
10,624 KB
testcase_15 AC 6 ms
10,624 KB
testcase_16 AC 5 ms
10,712 KB
testcase_17 AC 6 ms
10,644 KB
testcase_18 AC 5 ms
10,700 KB
testcase_19 AC 5 ms
10,568 KB
testcase_20 AC 6 ms
10,624 KB
testcase_21 AC 5 ms
10,588 KB
testcase_22 AC 5 ms
10,592 KB
testcase_23 AC 13 ms
12,712 KB
testcase_24 AC 20 ms
14,532 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 == 1) return 1;
	if (k == 0) return 0;
	if (n == 1) 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 = n, kk = k;
	while (x % d[m] == 0) {
		x /= d[m];
		kk--;
		//if (m + 1 != d.size()) if(x < d[m + 1]) break;
		ret += f(x, m + 1, kk);
		if (kk == 0) break;
	}

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

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