목차

Игра

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()