Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Song si woon #130

Merged
merged 2 commits into from
Jul 12, 2022
Merged

Song si woon #130

merged 2 commits into from
Jul 12, 2022

Conversation

SongSiWoon
Copy link
Collaborator

#118 문제풀이

2022-07-10
@SongSiWoon

문제

소스코드

  • 영화감독 숌(1436)
#include <iostream>
#include <string>
using namespace std;

int main(){
    int N;
    cin >> N;
    int start = 665;
    while (N > 0) {
        start++;
        if(to_string(start).find("666")!=string::npos) {
            N--;
        }
    }
    printf("%d", start);
}
  • 랜선 자르기(1654)
#include <iostream>
#include <algorithm>
using namespace std;


int main(){
    unsigned int K, N, res = 0;
    cin >> K >> N;
    unsigned int lens[K];
    for (int i = 0; i < K; ++i) {
        scanf("%d", &lens[i]);
    }

    unsigned int start = 1;
    unsigned int end = *max_element(lens, lens + K);
    unsigned int mid;
    unsigned int cnt = 0;
    while (start <= end) {
        cnt = 0;
        mid = (start + end) / 2;

        for (int i = 0; i < K; i++) {
            cnt += (lens[i] / mid);
        }

        if (cnt >= N) {
            start = mid + 1;
            res = max(mid, res);
        } else {
            end = mid - 1;
        }
    }
    cout << res;
}

@SongSiWoon SongSiWoon added C++ This code is wrote by C++ SongSiWoon🐯 labels Jul 9, 2022
@Dltmd202 Dltmd202 merged commit eb34e89 into master Jul 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C++ This code is wrote by C++ SongSiWoon🐯
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants