# 杰拉斯的博客

## [ACM_HDU_1410]PK武林盟主

### PK武林盟主

Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 621 Accepted Submission(s): 133

```
2 1 1 1
```

```
75.0000
```

#### Source

HDU1410

```N1 = HP2 / AP1;
N2 = HP1 / AP2;
```

```if(HP2 % AP1 > 0)
++N1;
if(HP1 % AP2 > 0)
++N2;
```

`C(N - 1, i) * pow(0.5, i) * pow(0.5) * N1;`

`C(N - 1, i) * pow(0.5, N1 + i);`

```#include<stdio.h>
#include<cmath>
int main()
{
int HP1, HP2, AP1, AP2, N1, N2;
while(scanf("%d%d%d%d", &HP1, &HP2, &AP1, &AP2) != EOF){
double ans = 0, tmp = 1;
N1 = HP2 / AP1;
N2 = HP1 / AP2;
if(HP2 % AP1 > 0)
++N1;
if(HP1 % AP2 > 0)
++N2;
ans = pow(0.5, N1);
for(int i = 1; i < N2; ++i){
tmp *= (N1 - 1 + i) / i;
ans += tmp * pow(0.5, N1 + i);
}
printf("%.4lf\n", ans * 100);
}
return 0;
}
```

```#include<stdio.h>
#include<cmath>
int main()
{
int HP1, HP2, AP1, AP2, N1, N2;
while(scanf("%d%d%d%d", &HP1, &HP2, &AP1, &AP2) != EOF){
double ans = 0, tmp = 0;
N1 = (HP2 - 1) / AP1 + 1;
N2 = (HP1 - 1) / AP2 + 1;
ans = pow(0.5, N1);
for(int i = 1; i < N2; ++i){
tmp += log10(N1 - 1.0 + i) - log10(i * 1.0);
ans += pow(10, tmp + (N1 + i) * log10(0.5));
}
printf("%.4lf\n", ans * 100);
}
return 0;
}
```