본문 바로가기

코드포스

[코드포스 Practice12] C. Given Length and Sum of Digits... -1 -1 안 되는 거 제외하기 그 후 되는 거 생각해보기 앞에서 부터 - 뒤에서 부터 힌트 받았당 최소 최대 전부 다 손코딩 했는데 북님이 더 깔끔한 코드를 알려주셨다. push_back() 최대랑 최소 그냥 역순 아닌가? 생각 들었는데 다른 점이 있어서 따로 짰다. 그런데 이거 조금 더 생각해보면 최소는 맨 첫자리가 1이어야 하므로 s-1을 구한 다음 첫번째 자리에 1을 더해주면 끝난다ㅋㅋ 짱신기함 #include #include using namespace std; int main() { int m, s; int start, end; scanf("%d %d", &m, &s); vector min_ans(m, 0); vector max_ans(m, 0); if (m == 1 && s == 0) { p.. 더보기
[코드포스 Practice12] B. New Year and Buggy Bot 코포 시간 내에 못 풀고 끝나고 다시 풀었다 이 문제를 복잡하게 생각해서 백트래킹을 써야하나??? 생각했는데 시간복잡도를 계산해보니 얼마 안 된다. 그래서 완전탐색으로 풀었다. 알고리즘까지는 바로 구현했는데 udlr 4!번 비교하는 데서 문제였다. 4! 섞어서 비교하는데?? 이거랑 mv 문자열이랑 비교를 어떻게 하지?? 싶었지만 어찌저찌 해결했다. #include #include #include #include using namespace std; int main() { int n, m; int s_i, s_j; cin >> n >> m; vector arr(n); string mv; string udlr = "0123"; int ans = 0; //input sort(udlr.begin(), udlr... 더보기
[코드포스 Practice12] A. k-rounding int count_num(i64 n, int div) { int count; count = 0; while (n > 0 && n % div == 0) { count++; n /= div; } return (count); } int main() { i64 n; int k; scanf("%lld %d", &n, &k); if (k == 0) { printf("%lld", n); return (0); } int a = count_num(n, 5); int b = count_num(n, 2); //cout 더보기
[코드포스 Practice12] 후기 11? 넘겨버렸다. 빨리 12 풀고싶었다. 아무튼.. 오랜만에 풀었는데 재밌었다. 한달동안 c언어로만 코딩했는데 갑자기 c++ 쓰려니 이차원 벡터 만드는 법도 까먹고 문자열 어떻게 했는지 까먹고.. 첫 문제 5트 정도 했는데 이유가 %lld로 안 적고 %ld로 적어서.. 내가 짰을 때는 잘 돌아가서 더 못 찾았다ㅋㅋ 맞왜틀 거리다 어이없어서 캡쳐도 해놨었다. 이번에는 어떻게 풀었는지 기억은 잘 안 나는데 A 25분 정도만에 풀고 틀려서 B로 넘어갔다. B는 문제 읽고 오래걸리겠다 싶어서 C로 넘어갔는데 C는 풀 수 없을 것 같아서 다시 A로 넘어와서 해결하고 남은 시간에는 B잡다가 끝난 듯. 빨리 풀이나 적어야지 더보기
[코드포스 Practice11] 후기 코포 10회까지는 음~ 두문제 해치우고 나머지 열심히 해야지! 이렇게 풀었는데 난이도 [800 - 1000 - 1200 - 1400 - 1600] -> [1200 - 1300 - 1400 - 1500 - 1600] 이렇게 올라서 A번 부터 머리 빡빡 굴리면서 풀었다. 빠ㅏ빠바빨간맛 매운맛 코포였음. 아무튼 풀다가 별별생각이 다 들었는데 처음 코포 풀 때 당황스러운 기억 떠올라서 괜히 추억에 잠겼다. 이제 이정도 난이도인거 아니깐 다음에는 마음 좀 다잡고 풀어야지. A - 14분 X 문제 이해를 못함 B - 16분 C - 14분 X 맞왜틀 D - X 이해는 했는데 풀지를 못하겠음 E - X 문제 읽다 끝남 나름 신경 쓴 건 모르겠으면 넘기기. 20분 기준으로 모르겠으면 다음 문제로 넘어갔다. 잘한 선택인것.. 더보기
[코드포스 Practice10] E. Military Problem (미완) In this problem you will have to help Berland army with organizing their command delivery system. 이 문제에서 너는 Berland 군대의 명령전달 시스템을 구성하는 것을 도와야 할것이다. There are n officers in Berland army. The first officer is the commander of the army, and he does not have any superiors. Every other officer has exactly one direct superior. If officer a is the direct superior of officer b, then we also can say that.. 더보기
[코드포스 Practice10] D. Alice and the List of Presents Alice got many presents these days. So she decided to pack them into boxes and send them to her friends. There are n kinds of presents. Presents of one kind are identical (i.e. there is no way to distinguish two gifts of the same kind). Presents of different kinds are different (i.e. that is, two gifts of different kinds are distinguishable). The number of presents of each kind, that Alice has i.. 더보기
[코드포스 Practice10] C. Video Posts Polycarp took n videos, the duration of the i-th video is ai seconds. The videos are listed in the chronological order, i.e. the 1-st video is the earliest, the 2-nd video is the next, ..., the n-th video is the last. Now Polycarp wants to publish exactly k (1≤k≤n) posts in Instabram. Each video should be a part of a single post. The posts should preserve the chronological order, it means that t.. 더보기