본문 바로가기

분류 전체보기

(111)
백준 14464 소가 길을 건너간 이유 4 (USACO February 2017 Silver 1번) 문제 링크: https://www.acmicpc.net/problem/14464 14464번: 소가 길을 건너간 이유 4 문제 농부 존의 소들은 효율적으로 길을 건너는 방법을 터득하고 있다. 그들은 길 건너기의 달인인 닭의 도움을 받기로 했다. 안타깝게도 닭은 매우 바쁜 동물이라, 소를 도와줄 시간이 별로 없다. 농장에 C마리(1 ≤ C ≤ 20,000)의 닭이 있고, 1번부터 C번까지 번호가 붙어 있다. i번 닭은 정확히 Ti초에만 소를 도와줄 수 있다. 하지만 닭은 길 건너기의 달인이므로 소를 데리고도 순식간에 길을 건널 수 있다. 소는 할 일이 없어서 여유롭게 길을 건 www.acmicpc.net Binary Search (lower_bound) 소가 A에서 B사이에 길을 건너는데, B를 기준으로 ..
백준 14454 Secret Cow Code (USACO January 2017 Silver 3번) 문제 링크: https://www.acmicpc.net/problem/14454 14454번: Secret Cow Code The cows are experimenting with secret codes, and have devised a method for creating an infinite-length string to be used as part of one of their codes. Given a string s, let F(s) be s followed by s "rotated" one character to the right (in a right rotation www.acmicpc.net 주어진 index가 길이가 두배가 되기전 어떤 index에서 온것인지 역추적 하면 됨. 예시 COW ..
백준 5959 Crop Circles (USACO January 2011 Bronze 4번) 문제 링크: https://www.acmicpc.net/problem/5959 5959번: Crop Circles Bessie and her fellow herd-mates have become extremely territorial. The N (1 > r[i]; for(int i = 0; i
백준 5958 Space Exploration (USACO January 2011 Bronze 3번) 문제 링크: https://www.acmicpc.net/problem/5958 5958번: Space Exploration Farmer John's cows have finally blasted off from earth and are now floating around space in their Moocraft. The cows want to reach their fiery kin on Jupiter's moon of Io, but to do this they must first navigate through the dangerous asteroid belt. Bessie www.acmicpc.net DFS component의 갯수를 세면 됨. 1 2 3 4 5 6 7 8 9 10 11 12 13 14..
백준 5957 Cleaning the Dishes (USACO January 2011 Bronze 2번) 문제 링크: https://www.acmicpc.net/problem/5957 5957번: Cleaning the Dishes Bessie and Canmuu are teaming up to wash the massive pile of N (1 n; for(int i = n; i >= 1; i--) a.push(i); while(c.size() != n) { int u, v; cin >> u >> v; if(u == 1) { while(v--) { b.push(a.top()); a.pop(); } } else { while(v--) { c.push(b.top()); b.pop(); } } } while(!c.empty()) { cout
백준 5956 Symmetry (USACO January 2011 Bronze 1번) 문제 링크: https://www.acmicpc.net/problem/5956 5956번: Symmetry Farmer John loves symmetry and is currently arranging his cows on his field partitioned into an N x M (1 m; int ans = 0, r = 1; while(n % 2 == 1 && m % 2 == 1) { ans += r; n /= 2; m /= 2; r *= 4; } cout
백준 5949 Adding Commas (USACO December 2010 Bronze 3번) 문제 링크: https://www.acmicpc.net/problem/5949 5949번: Adding Commas Bessie is working with large numbers N (1 s; int sz = s.size(); if(sz > 9) { s.insert(1, ","); s.insert(5, ","); s.insert(9, ","); } else if(sz > 6) { s.insert(sz - 6, ","); s.insert(sz - 2, ","); } else if(sz > 3) { s.insert(sz - 3, ","); } cout Colored by Color Scripter
백준 5948 Bad Random Numbers (USACO December 2010 Bronze 2번) 문제 링크: https://www.acmicpc.net/problem/5948 5948번: Bad Random Numbers Bessie is trying to generate random numbers. She stumbled upon an old reference to the 'middle square' method for making numbers that appear to be random. It works like this: Pick a starting four digit number (1 n; while(!v[n]) { v[n] = 1; n = n / 100 % 10 * 10 + n / 10 % 10; n *= n; ans++; } cout