Cod sursa(job #433975)
| Utilizator | Data | 4 aprilie 2010 20:44:58 | |
|---|---|---|---|
| Problema | Cifre | Scor | 30 |
| Compilator | c | Status | done |
| Runda | Arhiva de probleme | Marime | 0.54 kb |
#include <stdio.h>
long long a, b;
int c, k;
long long aux, i, nr;
long int sol;
float rez;
int cifre (long long x)
{
aux = x;
nr = 0;
while (aux)
{
if (aux % 10 == c)
nr ++;
aux /= 10;
}
return nr;
}
int main()
{
FILE *f = fopen ("cifre.in","r");
FILE *g = fopen ("cifre.out","w");
fscanf (f,"%lld %lld %lld %lld", &a, &b, &c, &k);
fclose(f);
for (i=a; i<=b; ++i)
{
if (cifre (i) >= k)
sol ++;
}
rez = (float) sol / (b-a+1);
fprintf (g,"%.4f", rez);
fclose(g);
return 0;
}
