結果

問題 No.469 区間加算と一致検索の問題
ユーザー 👑 はまやんはまやんはまやんはまやん
提出日時 2017-03-15 15:33:07
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,048 bytes
コンパイル時間 1,646 ms
コンパイル使用メモリ 178,108 KB
実行使用メモリ 10,892 KB
最終ジャッジ日時 2023-09-17 01:49:01
合計ジャッジ時間 9,435 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 RE -
testcase_34 RE -
testcase_35 RE -
testcase_36 RE -
testcase_37 RE -
testcase_38 RE -
testcase_39 RE -
testcase_40 RE -
testcase_41 RE -
testcase_42 RE -
testcase_43 RE -
testcase_44 RE -
testcase_45 RE -
testcase_46 RE -
testcase_47 RE -
testcase_48 WA -
testcase_49 WA -
testcase_50 RE -
testcase_51 RE -
権限があれば一括ダウンロードができます

ソースコード

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