#Miller-Rabinの素数判定法 def Miller_Rabin_Primality_Test(N,Times=20): """Miller-Rabinによる整数Nの素数判定を行う. N:整数 ※:Trueは正確にはProbably Trueである(Falseは確定False). """ from random import randint as ri if N==2: return True if N==1 or N%2==0: return False q=N-1 k=0 while q&1==0: k+=1 q>>=1 for _ in range(Times): m=ri(2,N-1) y=pow(m,q,N) if y==1: continue flag=True for i in range(k): if (y+1)%N==0: flag=False break y*=y y%=N if flag: return False return True #ポラード・ローアルゴリズムによって素因数を発見する #参考元:https://judge.yosupo.jp/submission/6131 def Find_Factor_Rho(N): if N==1: return 1 from math import gcd m=1<<(N.bit_length()//8+1) for c in range(1,99): f=lambda x:(x*x+c)%N y,r,q,g=2,1,1,1 while g==1: x=y for i in range(r): y=f(y) k=0 while k1: if Miller_Rabin_Primality_Test(N): res.append([N,1]) N=1 else: j=Find_Factor_Rho(N) k=0 while N%j==0: N//=j k+=1 res.append([j,k]) if N>1: res.append([N,1]) res.sort(key=lambda x:x[0]) return res #================================================ def General_Binary_Decrease_Search(L,R,cond,Integer=True,ep=1/(1<<20),Times=50): """条件式が単調減少であるとき,一般的な二部探索を行う. L:解の下限 R:解の上限 cond:条件(1変数関数,広義単調減少 or 広義単調減少を満たす) Integer:解を整数に制限するか? ep:Integer=Falseのとき,解の許容する誤差 """ if not(cond(L)): return None if cond(R): return R if Integer: L-=1 while R-L>1: C=L+(R-L)//2 if cond(C): L=C else: R=C return L else: while (R-L)>=ep and Times: Times-=1 C=L+(R-L)/2 if cond(C): L=C else: R=C return L def Floor_Root(a,k): """floor(a^(1/k)) を求める. a:非負整数 k:正の整数 """ assert 0<=a and 0a: x-=1 return x #================================================ def f(x): D=K*K+4*x R=Floor_Root(D,2) if R**2!=D: return None b=(-K+R) if b%2==1: return None else: return b//2 #================================================ from collections import defaultdict N,K,M=map(int,input().split()) #B=1の解の範囲を求める. alpha=General_Binary_Decrease_Search(0,N,lambda x:x*(x+K)<=N) #B>=2の解を求める. F=defaultdict(int) a=1 while a*(a+K)*(a+2*K)<=N: p=a*(a+K)*(a+2*K) F[p]+=1 q=a+3*K while p*q<=N: p*=q F[p]+=1 q+=K a+=1 if M>=2: Ans=0 for n in F: b=0 t=f(n) if t!=None and 1<=t<=alpha: b=1 if F[n]+b==M: Ans+=1 else: Ans=0 beta=alpha for n in F: if F[n]==1: t=f(n) if t==None or not(1<=t<=alpha): Ans+=1 else: beta-=1 else: t=f(n) if t!=None and 1<=t<=alpha: beta-=1 Ans+=beta print(Ans)