-
Notifications
You must be signed in to change notification settings - Fork 47
/
Copy path1093.c
54 lines (40 loc) · 891 Bytes
/
1093.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
@author: Malbolge;
@date: 23/07/2021;
@problem: Vampiros;
@subject: Math, Probability;
*/
#include <stdio.h>
#include <math.h>
double solve(int, int, int);
int main(int argc, char **argv)
{
double prob;
int ev1, ev2, at, d, tmp;
while (scanf("%d %d %d %d", &ev1, &ev2, &at, &d), ev1 && ev2 && at && d)
{
tmp = ev1;
ev1 = 0;
while (tmp > 0)
tmp -= d, ++ev1;
tmp = ev2;
ev2 = 0;
while (tmp > 0)
tmp -= d, ++ev2;
prob = solve(ev1, ev2, at);
printf("%.1f\n", prob * 100);
}
return 0;
}
double solve(int n1, int n2, int at)
{
if (at == 3)
return (double)n1 / (double)(n1 + n2);
else
{
double p;
p = 1.0 - (6 - at) / 6.0;
p = (1 - p) / p;
return (1.0 - pow(p, n1)) / (1.0 - pow(p, n1 + n2));
}
}