Cod sursa(job #2301296)

Utilizator BRIOI19Ben Test BRIOI19 Data 12 decembrie 2018 20:14:41
Problema Cifre Scor 70
Compilator cpp-64 Status done
Runda Arhiva de probleme Marime 0.65 kb
#include <bits/stdc++.h>


using namespace std;
const int N = 80000;
int checker(int check,int c){
    int ans = 0;
        do{
            if(check%10 == c){
                ans++;
            }
            check/=10;
        }while(check);
       return ans;
}
int main() {
    freopen("cifre.in","r",stdin);
    freopen("cifre.out","w",stdout);

    int a,b,c,k,check,count = 0;
    scanf("%d%d%d%d",&a,&b,&c,&k);

    
    srand(time(NULL));
    
    for(int i=1;i<=N;i++){
        check = a+rand()%(b-a+1);
       
        
        
        if(checker(check,c)>=k){
            count++;
        }
    }
   
        
        
    printf("%.4f\n",double(count)/N);
}