#include <iostream>
#include<cstdlib>
#include<ctime>
#include<cmath>
#define RPT 1000*1000*10
#define RPT_J 1
int main(){
    int number[1000]={0};
    for(auto nmbr = 0; nmbr<1000; nmbr++)
        number[nmbr]=0;
    long long i=0;
    long long j=0;
    long long digit_1 = 0;
    long long digit_2 = 0;
    long long digit_3 = 0;
    int z=0;
    double digit_prob[3];

    for(j=0; j < RPT_J; j ++)
    {
        for(i=0; i < RPT; i ++)
        {
            z=pow(1000, (rand()%(RAND_MAX))/static_cast<double>(RAND_MAX));
            if(z>99 && z<1000)
            {
                digit_3++;
            }
            else if (z>9 && z<100)
            {
                digit_2++;
            }
            else
            {
                digit_1++;
            }
            number[z%1000]++;
        }
        digit_prob[1 -1] = (100.d*digit_1/static_cast<double>(i*(j+1)));
        digit_prob[2 -1] = (100.d*digit_2/static_cast<double>(i*(j+1)));
        digit_prob[3 -1] = (100.d*digit_3/static_cast<double>(i*(j+1)));
        std::cout<<"J: "<<j+1<<std::endl;
        std::cout<<"1 digit : "<<digit_prob[1 -1]<<" %"<<std::endl;
        std::cout<<"2 digit : "<<digit_prob[2 -1]<<" %"<<std::endl;
        std::cout<<"3 digit: "<<digit_prob[3 -1]<<" %"<<std::endl;
    }
    for(auto nmbr = 1; nmbr<10; nmbr++)
        std::cout<<nmbr<<": "<<100.d*static_cast<double>(number[nmbr])/(i*j)<<" %"<<std::endl;
    return 0;
}

