백준 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 % ..
백준 18270 Livestock Lineup (USACO December 2019 Bronze 3번)
문제 링크: https://www.acmicpc.net/problem/18270 18270번: Livestock Lineup Every day, Farmer John milks his 8 dairy cows, named Bessie, Buttercup, Belinda, Beatrice, Bella, Blue, Betsy, and Sue. The cows are rather picky, unfortunately, and require that Farmer John milks them in an order that respects $N$ constraints ($1 \leq N \ www.acmicpc.net 소들을 알파벳 순서데로 정렬하고나서 모든 순열을 next_permutation을 이용하여 돌려보다가..