1266 소수완제품확률

2020. 3. 2. 09:48Learn/Algorithm

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
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
 
public class Solution {
    public static void main(String[] args) throws NumberFormatException, IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int Test = Integer.parseInt(br.readLine());
        double arrA[][] = new double [19][19];  
        double arrB[][] = new double [19][19];  
        int prime[] = {2,3,5,7,11,13,17};
        boolean find = false;
        for(int t = 1; t <= Test; t++) {
            StringTokenizer st = new StringTokenizer(br.readLine());
            double A = Integer.parseInt(st.nextToken());
            double B = Integer.parseInt(st.nextToken());
            A /= (double)100;
            B /= (double)100;
 
            double C = (double)1 - A;
            double D = (double)1 - B;
            arrA[0][0= 1;
            arrB[0][0= 1;
            for(int i = 1; i < 19; i++) {
                arrA[0][i] = arrA[0][i-1* A;
                arrA[i][0= arrA[i-1][0* C;
 
                arrB[0][i] = arrB[0][i-1* B;
                arrB[i][0= arrB[i-1][0* D;
                
            }
            for(int i = 1; i < 19; i++) {
                for(int j = 1; j < 19; j++) {
                    arrA[i][j] = arrA[i-1][j] * C + arrA[i][j-1* A;
                    arrB[i][j] = arrB[i-1][j] * D + arrB[i][j-1* B;
                }
            }
            double E = 0;
            double F = 0;
            for(int i = 0; i < prime.length; i++) {
 
                E += arrA[18-prime[i]][prime[i]];
                F += arrB[18-prime[i]][prime[i]];
            }
            E = (double)1 - E;
            F = (double)1 - F;
 
            double doi = 1 -(E*F);
            System.out.printf("#" + t + " " + "%7f \n", doi);
        }
    }
}
 
http://colorscripter.com/info#e" target="_blank" style="color:#4f4f4ftext-decoration:none">Colored by Color Scripter
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs

DP를 이용하여 풀었던 문제.

오른쪽 끝에서 왼쪽 아래까지 대각선 값을 구해주면 되는 문제였는데 거꾸로 가져와서

문제가 안풀렸던것 같다.

'Learn > Algorithm' 카테고리의 다른 글

1244 SWEA 최대상금  (0) 2020.02.18
3289. 서로소 집합 - SWexpert  (0) 2020.02.13
백준 4485 녹색 옷 입은 애가 젤다지?  (0) 2020.02.13
1258 SW Expert 행렬찾기  (0) 2020.02.11
11054 가장 긴 바이토닉 부분 수열  (0) 2020.02.11