Cod sursa(job #696665)

Utilizator techLaurentiu Avasiloaie tech Data 28 februarie 2012 19:28:21
Problema Cifre Scor 50
Compilator cpp Status done
Runda Arhiva de probleme Marime 0.48 kb
#include<stdio.h>
using namespace std;
long long int A,B,i;
float count,numar,rezultat;
int C,K,h,j;
int main()
{
	freopen("cifre.in", "r", stdin);
	scanf("%lld %lld", &A, &B);
	scanf("%d %d", &C, &K);
	count=0;
	for(i=A;i<=B;i++){
		h=i; j=0;
		while(h!=0 && j!=K){
			if(h%10==C){
				j++;
			}
			h=h/10;
		}
		if(j==K){
			count++;
		}
	}
	numar=1.0*(B-A+1);
	rezultat=count/numar;
	freopen("cifre.out", "w", stdout);
	printf("%1.4f", rezultat);
	return 0;
}