#include <iostream>
#include <cstdlib>
#include <ctime>
const int MAX = 10000;
int Prob (int num)
{
int Cnc = (std::rand() % MAX)+1;
if (Cnc <= num)
return 1;
else
return 0;
}
int main()
{
std::srand(std::time(NULL));
double positives = 0 ;
for(int n = 0; n < 10000; ++n)
positives += Prob(5000);
std::cout << "positives/MAX = " << positives / MAX << '\n';
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0ZGxpYj4KI2luY2x1ZGUgPGN0aW1lPgpjb25zdCBpbnQgTUFYID0gMTAwMDA7CmludCBQcm9iIChpbnQgbnVtKQp7CiAgIGludCBDbmMgPSAoc3RkOjpyYW5kKCkgJSBNQVgpKzE7CiAgIGlmIChDbmMgPD0gbnVtKQogICAgICAgcmV0dXJuIDE7CiAgIGVsc2UKICAgICAgIHJldHVybiAwOwp9CgppbnQgbWFpbigpCnsKICAgIHN0ZDo6c3JhbmQoc3RkOjp0aW1lKE5VTEwpKTsKICAgIGRvdWJsZSBwb3NpdGl2ZXMgPSAwIDsKICAgIGZvcihpbnQgbiA9IDA7IG4gPCAxMDAwMDsgKytuKQogICAgICAgIHBvc2l0aXZlcyArPSBQcm9iKDUwMDApOwogICAgc3RkOjpjb3V0IDw8ICJwb3NpdGl2ZXMvTUFYID0gIiA8PCBwb3NpdGl2ZXMgLyBNQVggPDwgJ1xuJzsKfQo=