Run ID 作者 问题 语言 测评结果 分数 时间 内存 代码长度 提交时间
38798 Gapple 【S】T1 C++ 通过 100 104 MS 380 KB 1012 2025-10-29 14:27:32

Tests(10/10):


#include <algorithm> #include <iostream> #include <vector> using namespace std; using i64 = long long; int m; i64 ans = 0; vector<i64> divisors; void solve(int layer, i64 val) { if (m <= 0) return; if (layer == 0 || val == 1) { --m; ans += val; return; } for (auto d : divisors) { if (d > val || m <= 0) break; if (val % d == 0) solve(layer - 1, d); } } int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); i64 x, k; cin >> x >> k >> m; if (k >= m) { cout << m << '\n'; return 0; } for (int i = 1; (i64)i * i <= x; ++i) { if (x % i != 0) continue; divisors.push_back(i); if ((i64)i * i != x) divisors.push_back(x / i); } sort(divisors.begin(), divisors.end()); solve(k, x); cout << ans << '\n'; return 0; }


测评信息: