이분탐색

· 백준이당
https://www.acmicpc.net/problem/11687#include using namespace std;int countZero(int n){ int cnt = 0; while (n >= 5) { cnt += n / 5; n /= 5; } return cnt;}int main(){ ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); int m; cin >> m; int bottom = 0, top = m * 5, ans = -1; while (bottom
https://www.acmicpc.net/problem/1654#include using namespace std;int main(){ ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); int k, n; cin >> k >> n; vector v(n); long long start = 1; long long end = 0; for (int i = 0; i > v[i]; end = max(end, v[i]); } long long cnt, mid; int line; while (start = n) { start = mid + 1; line..
· 백준이당
https://www.acmicpc.net/problem/2512기준 예산과 비교하면 된다.이분탐색할때 종료지점을 제대로 두자#include using namespace std;int main(){ ios::sync_with_stdio(0); cin.tie(0), cout.tie(0); int n; cin >> n; vector budget(n); for (int i = 0; i > budget[i]; } int plan; cin >> plan; int bottom = 0, top = *max_element(budget.begin(), budget.end()); int mid_val; int ans = 0; // 가능한 최대 상한값을 ..
이히당
'이분탐색' 태그의 글 목록