import java.util.*;
public class Solution {
// 2,3,5,7,11,13,17,19,23,29
static int[] check = { 0, 0, 1, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 0, 0, 1, 0 };
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int test = in.nextInt();
for (int t = 1; t <= test; t++) {
double winA = in.nextDouble() / (double) 100;
double winB = in.nextDouble() / (double) 100;
double combi = 1;
double answer = 0;
double totala = 0;
double totalb = 0;
for (int i = 1; i < 30; i++) {
combi *= (double) (31 - i) / i;
if (check[i] == 1) {
totala += combi * Math.pow(winA, i) * Math.pow((1 - winA), 30 - i);
totalb += combi * Math.pow(winB, i) * Math.pow((1 - winB), 30 - i);
}
}
answer = 1 - (1 - totala) * (1 - totalb);
System.out.printf("#%d %.5f\n", t, answer);
}
}
}
'알고리즘 공부' 카테고리의 다른 글
CodeJam: Qualification Round 2021 후기 (1) | 2021.03.27 |
---|---|
SWEA 1248: 공통조상 (0) | 2021.01.17 |
SWEA 1949: 등산로 조성 (0) | 2021.01.07 |
SWEA 1267: 작업순서 (0) | 2021.01.03 |
SWEA 5653: 줄기세포 배양 (0) | 2021.01.03 |