본문 바로가기

수학22

백준 23878 / C++ https://www.acmicpc.net/problem/23878 23878번: Lonely Photo Farmer John has recently acquired $N$ new cows $(3 \le N \le 5 \times 10^5)$, each of whose breed is either Guernsey or Holstein. The cows are currently standing in a line, and Farmer John wants take a photo of every sequence of three or more consecutive c www.acmicpc.net [ 풀이 ] 아이디어는 쉽습니다. 연속된 G끼리, H끼리 묶어서 개수를 구해줍니다. 우선 연속된 G를 기준으로 세봅시다.. 2022. 8. 23.
백준 23877 / C++ https://www.acmicpc.net/problem/23877 23877번: Convoluted Intervals In this example, for just $k=3$, there are three ordered pairs that will allow Bessie and Elie to win: $(1, 1)$, $(1, 2),$ and $(2, 1)$. www.acmicpc.net [ 풀이 ] N제한에 비해 M은 5000이므로 O(M^2)까진 가능하다. 구하는 값은 ai+aj n >> m; for (int i = 0; i > x >> y; A[x]++, B[y]++; } for (int i = 0; i 2022. 8. 23.
백준 14958 / C++ https://www.acmicpc.net/problem/14958 14958번: Rock Paper Scissors There is a Rock Paper Scissors (RPS) machine which generates Rock, Paper, or Scissors randomly. You also have a similar small Rock Paper Scissors machine. Before the game, the RPS machine will generate a list of its choice of Rock, Paper, or Scissors of th www.acmicpc.net [ 풀이 ] 매번 옮겨가면서 계산하면 O(mn)이다. FFT로 합성곱 구하는 과정을 NlogN에 해주자. .. 2022. 8. 22.
백준 11616 / C++ https://www.acmicpc.net/problem/11616 11616번: Digit Division We are given a sequence of n decimal digits. The sequence needs to be partitioned into one or more contiguous subsequences such that each subsequence, when interpreted as a decimal number, is divisible by a given integer m. Find the number of different suc www.acmicpc.net [ 풀이 ] 우선 짚고갈 것은 전체수가 m의 배수가 아니라면 m의 배수인 여러부분으로 분할할 수 없다. 이제 전체수.. 2022. 8. 12.