-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path508.java
More file actions
44 lines (38 loc) · 940 Bytes
/
508.java
File metadata and controls
44 lines (38 loc) · 940 Bytes
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
import java.util.*;
import java.io.*;
public class Solution {
public static void main (String [] args) {
Scanner in = new Scanner (new BufferedInputStream (System.in));
long C[][] = new long [51][51];
int n, l1, l2, rho;
n = in.nextInt ();
l1 = in.nextInt ();
l2 = in.nextInt ();
rho = in.nextInt ();
int a = 0, d, b = 0, i, j;
for (i = 0; i <= 50; ++i) {
C[i][i] = 1;
C[i][0] = 1;
}
for (i = 1; i <= 50; ++i)
for (j = 1; j < i; ++j)
C[i][j] = C[i-1][j] + C[i-1][j-1];
boolean flag = false;
for (d = 1; !flag && d <= n + 1; ++d) {
for (a = 0; a <= n && a + d - 1 <= n; ++a){
b = a + d - 1;
double nu = 0, de = 0;
for (int x = l1; x <= n - l2; ++x) {
if (x >= a && x <= b)
nu += C[x][l1] * C[n-x][l2];
de += C[x][l1] * C[n-x][l2];
}
if (nu * 100 >= rho * de) {
flag = true;
break;
}
}
}
System.out.printf("%d %d\n", a, b);
}
}