Cod sursa(job #402436)
Utilizator | Data | 23 februarie 2010 21:06:13 | |
---|---|---|---|
Problema | Pascal | Scor | 30 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.5 kb |
#include<stdio.h>
#include<math.h>
int functie(int n,int p)
{
int s=0;
int i=1;
while(pow(p,i)<=n)
{
s=s+n/pow(p,i);
i++;
}
return s;
}
int main()
{
freopen("pascal.in","r",stdin);
freopen("pascal.out","w",stdout);
int r,j,n,k1=0,k2=0,k3=0,d,p,c=0,i,q,s,t;
scanf("%d%d",&r,&d);
k1=functie(r,d);
for(j=0;j<=r;j++){
p=r-j;
k2=functie(p,d);
k3=functie(j,d);
if(k1-k2-k3>0){
c++;
}
k2=0;
k3=0;
}
printf("%d",c);
return 0;
}