-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path10_boj_1072.cpp
More file actions
44 lines (37 loc) · 867 Bytes
/
10_boj_1072.cpp
File metadata and controls
44 lines (37 loc) · 867 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
44
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
long long x,y,z;
long long nz;
int idx=0;
long long high=1000000000;
long long low=0;
int mid;
int result=-1;
int main() {
scanf("%lld %lld", &x, &y);
z = (100*y)/x;
// printf("initial z : %lld\n", z);
if ( z >= 99 ) { // z값 바뀌지 않는 조건
printf("-1\n");
return 0;
}
while (low <= high) {
mid = (high + low) / 2;
long long nx = x + mid;
long long ny = y + mid;
nz = (100 * ny) / nx;
// printf("high : %lld, low : %lld \n\n", high, low);
// printf("z : %lld, nz : %lld \n\n", z, nz);
if (nz > z) {
high = mid-1;
} else {
low = mid+1;
result = mid + 1;
}
}
printf("%d\n", result);
return 0;
}