#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;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZTxjc3RkbGliPgojaW5jbHVkZTxjdGltZT4KI2luY2x1ZGU8Y21hdGg+CiNkZWZpbmUgUlBUIDEwMDAqMTAwMCoxMAojZGVmaW5lIFJQVF9KIDEKaW50IG1haW4oKXsKICAgIGludCBudW1iZXJbMTAwMF09ezB9OwogICAgZm9yKGF1dG8gbm1iciA9IDA7IG5tYnI8MTAwMDsgbm1icisrKQogICAgICAgIG51bWJlcltubWJyXT0wOwogICAgbG9uZyBsb25nIGk9MDsKICAgIGxvbmcgbG9uZyBqPTA7CiAgICBsb25nIGxvbmcgZGlnaXRfMSA9IDA7CiAgICBsb25nIGxvbmcgZGlnaXRfMiA9IDA7CiAgICBsb25nIGxvbmcgZGlnaXRfMyA9IDA7CiAgICBpbnQgej0wOwogICAgZG91YmxlIGRpZ2l0X3Byb2JbM107CgogICAgZm9yKGo9MDsgaiA8IFJQVF9KOyBqICsrKQogICAgewogICAgICAgIGZvcihpPTA7IGkgPCBSUFQ7IGkgKyspCiAgICAgICAgewogICAgICAgICAgICB6PXBvdygxMDAwLCAocmFuZCgpJShSQU5EX01BWCkpL3N0YXRpY19jYXN0PGRvdWJsZT4oUkFORF9NQVgpKTsKICAgICAgICAgICAgaWYoej45OSAmJiB6PDEwMDApCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGRpZ2l0XzMrKzsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlIGlmICh6PjkgJiYgejwxMDApCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGRpZ2l0XzIrKzsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGRpZ2l0XzErKzsKICAgICAgICAgICAgfQogICAgICAgICAgICBudW1iZXJbeiUxMDAwXSsrOwogICAgICAgIH0KICAgICAgICBkaWdpdF9wcm9iWzEgLTFdID0gKDEwMC5kKmRpZ2l0XzEvc3RhdGljX2Nhc3Q8ZG91YmxlPihpKihqKzEpKSk7CiAgICAgICAgZGlnaXRfcHJvYlsyIC0xXSA9ICgxMDAuZCpkaWdpdF8yL3N0YXRpY19jYXN0PGRvdWJsZT4oaSooaisxKSkpOwogICAgICAgIGRpZ2l0X3Byb2JbMyAtMV0gPSAoMTAwLmQqZGlnaXRfMy9zdGF0aWNfY2FzdDxkb3VibGU+KGkqKGorMSkpKTsKICAgICAgICBzdGQ6OmNvdXQ8PCJKOiAiPDxqKzE8PHN0ZDo6ZW5kbDsKICAgICAgICBzdGQ6OmNvdXQ8PCIxIGRpZ2l0IDogIjw8ZGlnaXRfcHJvYlsxIC0xXTw8IiAlIj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