結果

問題 No.1973 Divisor Sequence
ユーザー kabipoyokabipoyo
提出日時 2022-06-10 22:23:23
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
MLE  
(最新)
AC  
(最初)
実行時間 -
コード長 1,826 bytes
コンパイル時間 4,948 ms
コンパイル使用メモリ 283,068 KB
実行使用メモリ 813,784 KB
最終ジャッジ日時 2023-10-21 06:21:24
合計ジャッジ時間 11,869 ms
ジャッジサーバーID
(参考情報)
judge11 / judge9
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 125 ms
52,984 KB
testcase_03 AC 10 ms
5,472 KB
testcase_04 AC 77 ms
32,264 KB
testcase_05 AC 29 ms
16,688 KB
testcase_06 AC 60 ms
31,668 KB
testcase_07 AC 18 ms
8,112 KB
testcase_08 AC 40 ms
18,076 KB
testcase_09 AC 69 ms
28,568 KB
testcase_10 AC 130 ms
44,672 KB
testcase_11 AC 17 ms
7,320 KB
testcase_12 AC 54 ms
26,124 KB
testcase_13 AC 22 ms
11,280 KB
testcase_14 AC 1,720 ms
124,008 KB
testcase_15 AC 188 ms
59,124 KB
testcase_16 AC 107 ms
45,592 KB
testcase_17 AC 110 ms
37,544 KB
testcase_18 AC 33 ms
7,320 KB
testcase_19 AC 144 ms
48,828 KB
testcase_20 AC 24 ms
8,904 KB
testcase_21 AC 77 ms
38,200 KB
testcase_22 AC 90 ms
38,004 KB
testcase_23 AC 697 ms
100,964 KB
testcase_24 MLE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
typedef int64_t lint;
#define rep(i, n) for(int i=0; i<n; i++)
#define repx(i, l, n) for(int i=l; i<n; i++)
#define all(v) v.begin(), v.end()
#define show(x) cout << #x << ": " << x << endl;
#define list(x) cout << #x << ": " << x << "  ";
#define pb push_back
using vi = vector<lint>;
using vvi = vector<vector<lint>>;
template<class T> inline void vin(vector<T>& v) { rep(i, v.size()) cin >> v.at(i); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> inline void drop(T x) { cout << x << endl; exit(0); }
template<class T> void vout(vector<T> v) { rep(i, v.size()) { cout << v.at(i) << ' '; } cout << endl; }
constexpr lint LINF = LLONG_MAX/2;
using mint = modint1000000007;
using vm = vector<mint>;
vector<lint> divisor(lint n) {
	vector<lint> v;
	for (lint i = 1; i*i <= n; i++) {
		if (n % i == 0) {
			v.push_back(i);
			if (i*i != n) v.push_back(n/i);
		}
	}
	sort(v.begin(), v.end());
	return v;
}
template<class T> map<T, int> coord_comp(set<T> s) {
	int a = 0;
	map<T, int> m;
	for (auto u : s) m[u] = ++a;
	return m;
}

int main() {
	lint N, M;
	cin >> N >> M;

	mint a=0, b=0, c=0;
	lint x, y, z;
	vi v = divisor(M);
	set<lint> s;
	z = v.size();
	rep(i, z) s.insert(v[i]);
	map<lint, int> m = coord_comp(s);
	vvi w(z);
	rep(i, z) {
		rep(j, z) {
			if (v[i] > LINF/v[j]) continue;
			if (s.count(v[i]*v[j])) {
				w[i].pb(j);
			}
		}
	}
	std::vector<vm> dp(N, vm(z));
	rep(i, z) {
		dp[0][i] = 1;
	}
	repx(i, 1, N) {
		rep(j, z) {
			rep(k, w[j].size()) {
				dp[i][w[j][k]] += dp[i-1][j];
			}
		}
	}
	rep(i, z) a += dp[N-1][i];
	std::cout << a.val() << '\n';
}
0