Cod sursa(job #299981)
Utilizator | Vlad Schnakovszki shnako | Data | 7 aprilie 2009 10:24:15 |
---|---|---|---|
Problema | Cifre | Scor | 40 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.66 kb |
#include <stdio.h>
FILE *f=fopen("cifre.in", "r"), *g=fopen("cifre.out", "w");
long x, i, a, b, c, k, sw, total, t;
void citeste(void)
{
fscanf(f, "%ld%ld%ld%ld", &a, &b, &c, &k);
total=b-a+1;
}
void rezolva(void)
{
for (i=a;i<=b;i++)
{
sw=0;
t=i;
while (t)
{
if (t%10==c)
sw++;
if (sw==k)
{
x++;
break;
}
t*=0.1;
}
}
}
void tipareste(void)
{
fprintf(g, "%.4f", (float)x/total);
fcloseall();
}
int main(void)
{
citeste();
rezolva();
tipareste();
return 0;
}