Created
January 3, 2021 06:03
-
-
Save hyperneutrino/0c30db691e7647614f0c277cb056ac70 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <algorithm> | |
#include <functional> | |
#include <iostream> | |
#include <random> | |
#include <string.h> | |
using namespace std; | |
const default_random_engine generator; | |
const uniform_int_distribution<int> distribution(1, 6); | |
int main() { | |
int c[7]; | |
srand(0); | |
auto dice = bind(distribution, generator); | |
int succ = 0; | |
for (int i = 0; i < 1000000; i++) { | |
fill(begin(c), end(c), 0); | |
int mv = 0; | |
for (int j = 0; j < 5; j++) mv = max(mv, ++c[dice()]); | |
for (int mi = 1; mi <= 6; mi++) { | |
if (c[mi] == mv) { | |
fill(begin(c), end(c), 0); | |
c[mi] = mv; | |
mv = 0; | |
for (int j = 0; j < 5 - c[mi]; j++) mv = max(mv, ++c[dice()]); | |
for (int mi = 1; mi <= 6; mi++) { | |
if (c[mi] == mv) { | |
fill(begin(c), end(c), 0); | |
c[mi] = mv; | |
mv = 0; | |
for (int j = 0; j < 5 - c[mi]; j++) mv = max(mv, ++c[dice()]); | |
if (mv == 5) succ++; | |
goto end; | |
} | |
} | |
} | |
} | |
end:; | |
} | |
cout << succ; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment