#include <iostream>
#include <cstdlib>
using namespace std;
const int REPEATS = 1000;
int main() {
int matches = 0;
for(int repeat = 0; repeat<REPEATS; repeat++) {
srand(time(NULL));
int x = rand()%1000000;
srand(time(NULL));
int y = rand()%1000000;
if(x==y){ //імовірність цієї події близька до 100%
matches++;
}
}
cout<<"matches: "<<matches<< " P(x==y)=" << double(matches)/REPEATS;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8Y3N0ZGxpYj4KdXNpbmcgbmFtZXNwYWNlIHN0ZDsKCmNvbnN0IGludCBSRVBFQVRTID0gMTAwMDsKCmludCBtYWluKCkgewoJaW50IG1hdGNoZXMgPSAwOwoJZm9yKGludCByZXBlYXQgPSAwOyByZXBlYXQ8UkVQRUFUUzsgcmVwZWF0KyspIHsKCQlzcmFuZCh0aW1lKE5VTEwpKTsKCQlpbnQgeCA9IHJhbmQoKSUxMDAwMDAwOwoJCXNyYW5kKHRpbWUoTlVMTCkpOwoJCWludCB5ID0gcmFuZCgpJTEwMDAwMDA7CgkJaWYoeD09eSl7IC8v0ZbQvNC+0LLRltGA0L3RltGB0YLRjCDRhtGW0ZTRlyDQv9C+0LTRltGXINCx0LvQuNC30YzQutCwINC00L4gMTAwJQoJCQltYXRjaGVzKys7CgkJfQoJfQoJY291dDw8Im1hdGNoZXM6ICI8PG1hdGNoZXM8PCAiIFAoeD09eSk9IiA8PCBkb3VibGUobWF0Y2hlcykvUkVQRUFUUzsKCXJldHVybiAwOwp9