#include <iostream>
#include<cstdlib>
#include<ctime>
#define RPT 3*1000*1000*10
#define RPT_J 2
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++)
{
int m=rand()%3+1;
if(m==3)
{
z=(int)rand()%900+100;
digit_3++;
}
else if(m==2)
{
z=(int)rand()%90+10;
digit_2++;
}
else if(m==1)
{
z=(int)rand()%10;
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 = 0; nmbr<10; nmbr++)
std::cout<<nmbr<<": "<<100.d*static_cast<double>(number[nmbr])/(i*j)<<" %"<<std::endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZTxjc3RkbGliPgojaW5jbHVkZTxjdGltZT4KI2RlZmluZSBSUFQgMyoxMDAwKjEwMDAqMTAKI2RlZmluZSBSUFRfSiAyCmludCBtYWluKCl7CiAgICBpbnQgbnVtYmVyWzEwMDBdPXswfTsKICAgIGZvcihhdXRvIG5tYnIgPSAwOyBubWJyPDEwMDA7IG5tYnIrKykKICAgICAgICBudW1iZXJbbm1icl09MDsKICAgIGxvbmcgbG9uZyBpPTA7CiAgICBsb25nIGxvbmcgaj0wOwogICAgbG9uZyBsb25nIGRpZ2l0XzEgPSAwOwogICAgbG9uZyBsb25nIGRpZ2l0XzIgPSAwOwogICAgbG9uZyBsb25nIGRpZ2l0XzMgPSAwOwogICAgaW50IHo9MDsKICAgIGRvdWJsZSBkaWdpdF9wcm9iWzNdOwoKICAgIGZvcihqPTA7IGo8UlBUX0o7aisrKQogICAgewogICAgICAgIGZvcihpPTA7IGk8UlBUO2krKykKICAgICAgICB7CiAgICAgICAgICAgIGludCBtPXJhbmQoKSUzKzE7CiAgICAgICAgICAgIGlmKG09PTMpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIHo9KGludClyYW5kKCklOTAwKzEwMDsKICAgICAgICAgICAgICAgIGRpZ2l0XzMrKzsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlIGlmKG09PTIpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIHo9KGludClyYW5kKCklOTArMTA7CiAgICAgICAgICAgICAgICBkaWdpdF8yKys7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgZWxzZSBpZihtPT0xKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICB6PShpbnQpcmFuZCgpJTEwOwogICAgICAgICAgICAgICAgZGlnaXRfMSsrOwogICAgICAgICAgICB9CiAgICAgICAgICAgIG51bWJlclt6JTEwMDBdKys7CiAgICAgICAgfQogICAgICAgIGRpZ2l0X3Byb2JbMSAtMV0gPSAoMTAwLmQqZGlnaXRfMS9zdGF0aWNfY2FzdDxkb3VibGU+KGkqKGorMSkpKTsKICAgICAgICBkaWdpdF9wcm9iWzIgLTFdID0gKDEwMC5kKmRpZ2l0XzIvc3RhdGljX2Nhc3Q8ZG91YmxlPihpKihqKzEpKSk7CiAgICAgICAgZGlnaXRfcHJvYlszIC0xXSA9ICgxMDAuZCpkaWdpdF8zL3N0YXRpY19jYXN0PGRvdWJsZT4oaSooaisxKSkpOwogICAgICAgIHN0ZDo6Y291dDw8Iko6ICI8PGorMTw8c3RkOjplbmRsOwogICAgICAgIHN0ZDo6Y291dDw8IjEgZGlnaXQgOiAiPDxkaWdpdF9wcm9i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