본문 바로가기

분류 전체보기

(111)
백준 5940 Math Practice (USACO November 2010 Bronze 3번) 문제 링크: https://www.acmicpc.net/problem/5940 5940번: Math Practice One lovely afternoon, Bessie's friend Heidi was helping Bessie review for her upcoming math exam. Heidi presents two integers A (0 B; for(int i = A + 1; i 9) n /= 10; if(n == B) { cout
백준 5939 Race Results (USACO November 2010 Bronze 2번) 문제 링크: https://www.acmicpc.net/problem/5939 5939번: Race Results The herd has run its first marathon! The N (1
백준 5938 Daisy Chains in the Field (USACO November 2010 Bronze 1번) 문제 링크: https://www.acmicpc.net/problem/5938 5938번: Daisy Chains in the Field Farmer John let his N (1 > u >> v; adj[u].push_back(v); adj[v].push_back(u); } dfs(1); if(cnt == n) cout
백준 18788 Swapity Swap (USACO February 2020 Bronze 3번) 문제 링크: https://www.acmicpc.net/problem/18788 18788번: Swapity Swap Initially, the order of the cows is $[1,2,3,4,5,6,7]$ from left to right. After the first step of the process, the order is $[1,5,4,3,2,6,7].$ After the second step of the process, the order is $[1,5,7,6,2,3,4]$. Repeating both steps a second time yields t www.acmicpc.net 배열의 처음 상태로 몇번만에 돌아오는지 period를 먼저 계산하고, 실제로 k번을 반복하는 대신 k % ..
백준 18787 Mad Scientist (USACO February 2020 Bronze 2번) 문제 링크: https://www.acmicpc.net/problem/18787 18787번: Mad Scientist First, FJ can transform the substring that corresponds to the first character alone, transforming $B$ into GHGGGHH. Next, he can transform the substring consisting of the third and fourth characters, giving $A$. Of course, there are other combinations of t www.acmicpc.net 예시 7 GHHHGHH HHGGGHH 앞에서부터 훑으면서 첫번째 자리가 다르므로 한번 toggle해주고,..
백준 18786 Triangles (USACO February 2020 Bronze 1번) 문제 링크: https://www.acmicpc.net/problem/18786 18786번: Triangles (Bronze) Posts at $(0,0)$, $(1,0)$, and $(1,2)$ form a triangle of area $1$. Thus, the answer is $2\cdot 1=2$. There is only one other triangle, with area $0.5$. www.acmicpc.net 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 #include using namespace std; struct coord { int x, y; }; int n; coord..
백준 2309 일곱 난쟁이 (KOI 지역본선 2004 초등부 1번) 문제 링크: https://www.acmicpc.net/problem/2309 2309번: 일곱 난쟁이 아홉 개의 줄에 걸쳐 난쟁이들의 키가 주어진다. 주어지는 키는 100을 넘지 않는 자연수이며, 아홉 난쟁이의 키는 모두 다르며, 가능한 정답이 여러 가지인 경우에는 아무거나 출력한다. www.acmicpc.net 9명의 난쟁이의 키를 입력 받으면서 총 합을 같이 구함. sort한후, 각 pair의 키들을 총 합에서 뺀값이 100일때를 찾고, 그때 나머지 7명의 키를 출력하면 됨. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 #include using namespace std; int height[10];..
백준 18323 Photoshoot (USACO January 2020 Bronze 2번) 문제 링크: https://www.acmicpc.net/problem/18323 18323번: Photoshoot Farmer John is lining up his $N$ cows ($2\le N\le 10^3$), numbered $1\ldots N$, for a photoshoot. FJ initially planned for the $i$-th cow from the left to be the cow numbered $a_i,$ and wrote down the permutation $a_1,a_2,\ldots,a_N$ on a sheet of paper. U www.acmicpc.net 예시 1 5 4 6 7 6 첫수를 1부터 4 - 1 까지 시도해 보면서 가능할때 출력하면 됨. 첫수가 1일때:..