-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1072.java
More file actions
37 lines (32 loc) · 1006 Bytes
/
1072.java
File metadata and controls
37 lines (32 loc) · 1006 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
import java.io.*;
import java.util.StringTokenizer;
public class Main {
static long X, Y, Z;
static long l, r, answer;
public static void main(String[] args) throws Exception {
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
StringTokenizer st = new StringTokenizer(br.readLine());
X = Long.parseLong(st.nextToken());
Y = Long.parseLong(st.nextToken());
answer = X;
Z = Y * 100 / X;
if (Z >= 99) {
System.out.println(-1);
} else {
l = 0;
r = X;
while (l <= r) {
long mid = (l + r) / 2;
long rate = (Y + mid) * 100 / (X + mid);
if (rate != Z) {
answer = answer < mid ? answer : mid;
r = mid - 1;
} else {
l = mid + 1;
}
}
System.out.println(answer);
}
br.close();
}
}