문제
https://www.acmicpc.net/problem/1072
해설
n의 값이 크기 때문에 이분 탐색을 이용함
코드
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
|
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll x, y, ret =-1, tmp,low,mid,hi,z;
int main(){
cin >> x >>y ;
z = (y*100)/x;
low = 1; hi = 1e9;
while(low <= hi){
mid = (low+hi)/2;
if(((y+mid)*100)/(mid+x)>z){
ret = mid;
hi = mid-1;
}
else{
low = mid+1;
}
}
cout << ret;
return 0;
}
|
cs |
'백준 알고리즘(C++)' 카테고리의 다른 글
백준 17070번 파이프 옮기기 1 ( C++ ) (0) | 2024.09.15 |
---|---|
백준 2098번 외판원 순회 ( C++ ) (0) | 2024.09.15 |
백준 16434번 드래곤 앤 던전 ( C++ ) (0) | 2024.09.10 |
백준 1269번 대칭 차집합 ( C++ ) (0) | 2024.09.10 |
백준 7795번 먹을 것인가 먹힐 것인가 ( C++ ) (0) | 2024.09.10 |