WookjeBlog
    • 블로그
    • 소개
    • 태그
    • 수업/강의
    • 라이브러리

    Wookje blog

    알고리즘 블로그였던 것

    Featured Posts
    • [BOJ] 1120 : 문자열

      1120 : 문자열 풀이 그리디하게 풀어보자. a의 길이가 b보다 짧으므로 a[i] != b[j]의 개수가 가장 짧은 구간을 택하면 아무 문자나 양옆으로 붙일 수 있으므로 최소의 a[i] != b[j] 합이 답이 된다. 코드 #include <cstdio> #include <cstring> char a[55], b[55]; int alen, blen, sum, min = 1e9, i, j; int main() { scanf("%s %s", a, b); alen = strlen(a); for (; b[i + alen - 1]; i++, sum = 0) { for (j = 0; a[j];...

      boj greedy string

      wookje.kwon's profile image

      wookje.kwon

      2018-03-22 10:10

    • [BOJ] 1075 : 나누기

      1075 : 나누기 풀이 저 푸른 초원 위에 그림 같은 집을 짓고 코드 #include <stdio.h> int a, b, i; int main() { scanf("%d %d", &a, &b); a /= 100; a *= 100; for (; i <= 100; i++) if ((a + i) % b == 0) return ~printf("%02d", (a + i) % 100); return 0; } 아무말 백준, 백준 온라인 저지, BOJ, Baekjoon Online Judge, C, C++, 씨, 씨쁠쁠, JAVA, algorithm, 자바, 알고리즘, 자료구조, 문제,...

      boj naive math

      wookje.kwon's profile image

      wookje.kwon

      2018-03-22 09:56

    • [BOJ] 1015 : 수열 정렬

      1015 : 수열 정렬 풀이 졸리다 코드 #include <stdio.h> #include <algorithm> using namespace std; int n, i, b[55]; pair<int, int> a[55]; int main() { scanf("%d", &n); while (i < n) scanf("%d", &a[i].first), a[i].second = i, i++; sort(a, a + n); while (i--) b[a[i].second] = i; i++; while (i < n) printf("%d ", b[i++]); return 0; } 아무말 백준, 백준 온라인 저지, BOJ, Baekjoon Online Judge, C, C++, 씨, 씨쁠쁠, JAVA, algorithm, 자바, 알고리즘, 자료구조, 문제,...

      boj sort

      wookje.kwon's profile image

      wookje.kwon

      2018-03-22 09:44

    • [BOJ] 1806 : 부분합

      1806 : 부분합 풀이 종강 언제지 코드 #include <stdio.h> #include <algorithm> int n, m, r = 1e9, a[100001]; int main() { scanf("%d %d", &n, &m); for (int i = 1, j = 0; i <= n; i++) { scanf("%d", &a[i]); a[i] += a[i - 1]; for (; a[i] - a[j] >= m; j++) r = std::min(r, i - j); } printf("%d", r == 1e9 ? 0 : r); return 0; } 아무말 백준, 백준 온라인...

      boj two-pointer

      wookje.kwon's profile image

      wookje.kwon

      2018-03-21 09:51

    • [BOJ] 2003 : 수들의 합 2

      2003 : 수들의 합 2 풀이 투포인터 조아!! 분할정복도 조아!! 코드 #include <stdio.h> int n, m, k, s, a[10001]; int main() { scanf("%d %d", &n, &m); for (int i = 0, j = 0; i < n; i++) { scanf("%d", &a[i]); s += a[i]; while (s > m) s -= a[j++]; k += (s == m); } printf("%d", k); return 0; } #include <cstdio> #include <algorithm> using namespace std; int n, k, a[10001], sum[10001]; int...

      boj two-pointer divide-and-conquer

      wookje.kwon's profile image

      wookje.kwon

      2018-03-19 20:24

    • [BOJ] 1493 : 박스 채우기

      1493 : 박스 채우기 풀이 ! 큐브러버님 코드 참고했습니다 ! 가장 큰 큐브부터 사용해서 박스를 채워야 하는 것은 증명할 것도 없이 자명하다. 부피로 으쌰으쌰 슥삭슥삭 멋있게 잘 계산해서 빈 공간을 잘 채워넣으면 된다. 사용했던 큐브를 보다 작은 단위로 쪼개나가자. 1*1*1 단위까지 쪼개지면, 그 큐브의 개수가 박스의 부피와 같은지를 비교해주자. 코드 #include <cstdio> #include <algorithm> typedef long long ll; int l, w, h, n; int a[22]; ll cnt, ans; int main() { scanf("%d %d %d %d",...

      boj bitmask string

      wookje.kwon's profile image

      wookje.kwon

      2018-03-19 11:12

    • [BOJ] 12025 : 장난꾸러기 영훈

      12025 : 장난꾸러기 영훈 풀이 아 9시 수업 에반데 코드 #include <stdio.h> long long i, k; char s[66]; int main() { scanf("%s %lld", s, &k); k--; for (i = 0; s[i]; i++) { if (s[i] == '6' || s[i] == '7') s[i] -= 5; } while (i--) { if (s[i] == '1' || s[i] == '2') { if (k & 1) s[i] += 5; k >>= 1; } } puts(k ? "-1" : s); return...

      boj bitmask string

      wookje.kwon's profile image

      wookje.kwon

      2018-03-19 09:51

    • [BOJ] 2212 : 센서

      2212 : 센서 풀이 각각의 좌표들을 정렬해보자. 그리고 인접한 좌표들의 거리 차이를 구해보자. 그리고 그 거리 차이를 다시 정렬해보자. k개의 집중국, 다시 말해 k개의 직선을 놓는다면 k-1개의 빈 공간(?)이 생기게 만들 수 있다. 그러므로 방금 정렬한 거리 차이 중에서 가장 큰 값을 k-1개 고르면 집중국이 차지하는 영역(?)의 합이 최소가 될 것이고 답을 구할 수 있다 (!!) 코드 #include <stdio.h> #include <algorithm> int n, k, ans, a[10001]; int main() { scanf("%d %d", &n, &k); for (int...

      boj greedy

      wookje.kwon's profile image

      wookje.kwon

      2018-03-15 10:08

    • [BOJ] 1969 : DNA

      1969 : DNA 풀이 음 사실 그리디인지는 잘 모르겠고 그냥 나이브하게 짜면 된다. 코드 #include <stdio.h> int n, m, d, cnt[51][26]; char s[1001][51], r[1001]; int main() { scanf("%d %d", &n, &m); for (int i = 0; i < n; i++) { scanf("%s", s[i]); for (int j = 0; j < m; j++) cnt[j][s[i][j] - 'A']++; } for (int i = 0; i < m; i++) { int mx = 0; for (int j = 0;...

      boj greedy string

      wookje.kwon's profile image

      wookje.kwon

      2018-03-14 14:34

    • [BOJ] 2217 : 로프

      2217 : 로프 풀이 로프의 무게를 내림차순으로 정렬해서 무게를 달아보자! i번째 로프에 걸리는 중량은 weight / i이다. 가장 튼튼한 로프에 걸리는 중량을 w[1]이라고 할 때 w[i] (i != 1)은 항상 w[1]보다 작으므로 중량을 하나씩 걸어보면서 max값을 찾으면 된다. 코드 #include <stdio.h> #include <algorithm> int main() { int n, i, a[100001], k = -1; scanf("%d", &n); for (i = 0; i < n; ++i) scanf("%d", &a[i]); std::sort(a, a + n); for (i = 0; i <...

      boj greedy

      wookje.kwon's profile image

      wookje.kwon

      2018-03-14 12:38

    • Previous Page
    • 21
    • 22
    • 23
    • 24
    • 25
    • Next Page
    • github
    • facebook
    • rss

    Copyright © Wookje Kwon. All rights reserved.