Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🧷 문제 링크
https://www.acmicpc.net/problem/31424
🧭 풀이 시간
80분
👀 체감 난이도
✏️ 문제 설명
칠판에 수 X가 적혀있다. 두 명의 사람이 N개의 카드 뭉치에서 번갈아가며 한 장씩 고른다. 고른 수와 X의 최대공약수가 1이 아니어야 하며, X를 그 최대공약수로 바꾼다.
더 이상 고를 수 없는 사람이 패배할 때, 선공이 이기는지 후공이 이기는지 알아보자.
🔍 풀이 방법
X를 소인수분해한 결과를 p1^q1 * p2^q2 * ... 라고 하자.
각 소수가 몇 번 곱해졌는지는 어차피 중요하지 않고, 그 소수를 포함하는지의 여부만이 게임의 상태를 바꾼다.
여기에 포함된 소수의 종류 집합을 S라고 하면,
X <= 10^9이기 때문에 |S| <= 9가 된다.
따라서, 가능한 상태는 2^9가지 경우로 좁혀진다.
ex[i][k] = 카드 뭉치에서 중복 없이 i개를 골랐을 때 상태가 k가 될 수 있으면 1, 아니면 0으로 둔다.
상태의 기저들에 대한 최대 깊이가 홀수인 경우가 존재하면 선공 승, 아니면 후공 승으로 판정했다.
⏳ 회고
근데 틀렸다. 그냥 로직이 잘못된 거 같은데 못 고치겠음