Cod sursa(job #719258)
Utilizator | Data | 21 martie 2012 17:43:29 | |
---|---|---|---|
Problema | Cifre | Scor | 40 |
Compilator | cpp | Status | done |
Runda | Arhiva de probleme | Marime | 0.5 kb |
#include <cstdio>
using namespace std;
long long a,b,c,k,i,aux,sol,cnt;
float p;
int main()
{
FILE *f=fopen("cifre.in","r");
FILE *g=fopen("cifre.out","w");
fscanf(f,"%lld %lld",&a,&b);
fscanf(f,"%lld %lld",&c,&k);
sol=0;
for(i=a;i<=b;i++)
{
aux=i;
cnt=0;
while(aux>0&&cnt<k){if(c==aux%10)cnt++;aux/=10;}
if(cnt==k)sol++;
}
p=(float)sol/(b-a+1);
fprintf(g,"%.4f",p);
fclose(f);
fclose(g);
return 0;
}