#define rep(i, n) for (int i = 0; i < (int)(n); i++) #define ALL(v) v.begin(), v.end() typedef long long ll; #include using namespace std; const double EPS=1e-9; ll n,k,m; bool f(ll x){ if(n<1e6) return false; double l=1e6; double r=n; rep(i,50){ double a=(l+r)/2; if(a*a+k*a-x>EPS) r=a; else if(a*a+k*a-x<-EPS) l=a; } if(abs(r-round(r))>n>>k>>m; map M; for(ll a=1;a<1000000;a++){ ll tmp=a; for(ll b=1;;b++){ if(log(tmp)+log(a+b*k)>log(n)) break; tmp*=a+b*k; M[tmp]++; } } ll ans=0; if(m>=2){ for(auto x:M){ if(x.second==m && f(x.first)==false) ans++; if(x.second==m-1 && f(x.first)==true) ans++; } } if(m==1){ ans+=max(0LL,n-1000000LL); for(auto x:M){ if(f(x.first)==true) ans--; if(x.second==m && f(x.first)==false) ans++; } } cout<