28 lines
569 B
C
28 lines
569 B
C
|
#include <stdio.h>
|
||
|
|
||
|
int main()
|
||
|
{
|
||
|
int iterations = 256*256*256;
|
||
|
int successes_amount = 0;
|
||
|
|
||
|
for (int a = 0; a < 256; a++)
|
||
|
{
|
||
|
for (int b = 0; b < 256; b++)
|
||
|
{
|
||
|
for (int c = 0; c < 256; c++)
|
||
|
{
|
||
|
if (a + b + c > 300)
|
||
|
{
|
||
|
successes_amount++;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
|
||
|
printf("Iterations: %d\n", iterations);
|
||
|
printf("Valid sums: %d\n", successes_amount);
|
||
|
printf("Probability: %f\n", (float) successes_amount / iterations);
|
||
|
|
||
|
return 0;
|
||
|
}
|