Cod sursa(job #34033)

Utilizator RobytzzaIonescu Robert Marius Robytzza Data 19 martie 2007 23:41:51
Problema Cifre Scor 20
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.44 kb
#include<fstream.h>
int main(){
ifstream fin("cifre.in");
ofstream fout("cifre.out");
long int a,b,x,p=1;
double z=0;
short  c,k=0,nr=0,s=0;
fin>>a>>b>>c>>k;
while (s<k-1) {
	s++;
	p*=10;}
for (long int i=p;i<=b;i++){
		    x=i;
		    nr=0;
		for (short y=0;y<k;y++){
		     if (x%10==c)
			 nr++;
			 x/=10; }
		if (nr>=k)
		    z++;}
long int h=b-a;
  z/=(h+1);
  fout<<z<<"\n";
fin.close();
fout.close();
return 0;
}