-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBOJ1344.java
More file actions
48 lines (38 loc) · 1.19 KB
/
BOJ1344.java
File metadata and controls
48 lines (38 loc) · 1.19 KB
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
package quki.algorithm.dp;
import java.util.Scanner;
public class BOJ1344 {
public static boolean isPrime(int i){
if(i == 2 || i == 3 || i == 5 || i == 7 || i == 11 || i == 13 || i == 17){
return true;
}
return false;
}
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
int A = sc.nextInt();
int B = sc.nextInt();
int d[] = new int[19];
double a[] = new double[19];
double b[] = new double[19];
d[0] = 1;
d[1] = 18;
double Ateam = A / 100.0;
double Bteam = B / 100.0;
for (int i = 2; i <= 18; i++) {
d[i] = (19 - i) * d[i - 1] / i;
}
for (int i = 0; i <= 18; i++) {
a[i] = d[i] * Math.pow(Ateam, i) * Math.pow(1 - Ateam, 18 - i);
b[i] = d[i] * Math.pow(Bteam, i) * Math.pow(1 - Bteam, 18 - i);
}
double aSum = 0.0;
double bSum = 0.0;
for (int i = 0; i <= 18; i++) {
if(!isPrime(i)){
aSum += a[i];
bSum += b[i];
}
}
System.out.println(1- aSum*bSum);
}
}