Cod sursa(job #105170)
Utilizator | Popa Marius Ionut mariaci | Data | 17 noiembrie 2007 10:39:27 |
---|---|---|---|
Problema | Cifre | Scor | 50 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.43 kb |
#include<stdio.h>
long a,b,c,k;
int cif(int x)
{ int aux=0;
while(x)
{ if(x%10==c) aux++;
x=x/10;
if(aux==k) return 1;
}
return 0;
}
int main()
{ freopen("cifre.in","r",stdin);
freopen("cifre.out","w",stdout);
scanf("%d %d %d %d",&a,&b,&c,&k);
int aux=0;
for(long i=a;i<=b;i++)
if(cif(i)) aux++;
printf("%.4f",(float)aux/(b-a+1));
fclose(stdin);
fclose(stdout);
return 0;
}