알고리즘 공부
SWEA 3462: 선표의 축구 경기 예측
소연쏘
2021. 1. 10. 23:49
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);
}
}
}