| ps | |
|---|---|
| 링크 | acmicpc.net/… |
| 출처 | BOJ |
| 문제 번호 | 29042 |
| 문제명 | Игра |
| 레벨 | 골드 5 |
| 분류 |
게임이론 |
| 시간복잡도 | O(sqrt(n)) |
| 인풋사이즈 | n<=10^9 |
| 사용한 언어 | Python 3.13 |
| 제출기록 | 34536KB / 36ms |
| 최고기록 | 36ms |
| 해결날짜 | 2025/09/24 |
"""Solution code for "BOJ 29042. Игра".
- Problem link: https://www.acmicpc.net/problem/29042
- Solution link: http://www.teferi.net/ps/problems/boj/29042
Tags: [game theory]
"""
import math
from teflib import numtheory
def main():
A, B, C = [int(x) for x in input().split()]
g = math.gcd(A, B)
a_score = sum(
e
for p, e in numtheory.prime_factorization_small(A // g).items()
if p <= C
)
b_score = sum(
e
for p, e in numtheory.prime_factorization_small(B // g).items()
if p <= C
)
print('First' if a_score > b_score else 'Second')
if __name__ == '__main__':
main()