#include #include #include #include #include #include #include #include #include #include #include #include #define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl; #define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl; template inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } template inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; } using namespace std; typedef long long ll; const ll INF = 2e18; ll calc(ll a, ll b, ll k){ ll ans = a; for(ll i = 1; i <= b; i++){ ll x = a+k*i; if(ans >= INF/x) return INF; ans *= x; } // cout << "calc(" << a << "," << b << "," << k << ") = " << ans << endl; return ans; } ll f(ll x, ll k){ ll l = 0, r = 1e9; while(r-l > 1){ ll c = (l+r)/2; if(c*(c+k) > x) r = c; else l = c; } return l; } int naive(ll n, ll k, ll m){ map cnt; for(int b = 1; ; b++){ if(calc(1, b, k) > n) break; for(int a = 1; ; a++){ ll x = calc(a, b, k); if(x > n) break; if(cnt.count(x) == 0) cnt[x] = 1; else cnt[x]++; } } int ans = 0; for(auto [_, c]: cnt){ if(c == m) ans++; } return ans; } int main(){ ios::sync_with_stdio(false); cin.tie(0); cout << setprecision(10) << fixed; ll n, k, m; cin >> n >> k >> m; map cnt; for(int b = 2; ; b++){ if(calc(1, b, k) > n) break; for(int a = 1; ; a++){ ll x = calc(a, b, k); if(x > n) break; if(cnt.count(x) == 0) cnt[x] = 1; else cnt[x]++; } } vector v; for(auto &[x, c]: cnt) { ll y = f(x, k); if(y*(y+k) == x){ v.push_back(x); c++; } } int ans = 0; for(auto [_, c]: cnt){ if(c == m) ans++; } if(m == 1){ ll y = f(n, k); ans += y; for(auto [x, c]: cnt){ ll y = f(x, k); if(y*(y+k) == x) ans--; } } cout << ans << endl; // cout << naive(n, k, m) << endl; }