Cod sursa(job #2301250)

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


using namespace std;

int main() {
    ifstream fin("cifre.in");
    ofstream fout("cifre.out");
    int a,b,c,k;
    fin>>a>>b>>c>>k;
    int den = b-a+1;
    srand(time(0));
    int count = 0;
    for(int i=1;i<=500500;i++){
        int check = a+rand()%(den);
       
        int ans = 0;
        do{
            if(check%10 == c){
                ans++;
            }
            check/=10;
        }while(check);
       
        
        if(ans>=k){
            count++;
        }
    }
    fout<<setprecision(4)<<(double)count/500500;
}