목차

정사각형

ps
링크acmicpc.net/…
출처BOJ
문제 번호3614
문제명정사각형
레벨골드 2
분류

정수론

시간복잡도O(n^(5/6))
인풋사이즈n<=10^6
사용한 언어Python 3.13
제출기록34536KB / 36ms
최고기록36ms
해결날짜2026/01/25

풀이

코드

"""Solution code for "BOJ 3614. 정사각형".

- Problem link: https://www.acmicpc.net/problem/3614
- Solution link: http://www.teferi.net/ps/problems/boj/3614

Tags: [number theory]
"""

from teflib import numtheory


def main():
    N = int(input())
    count = sum(
        numtheory.euler_phi_small(g + 1)
        for g in numtheory.all_divisors_small(N)
    )
    print((count + 1) // 2)


if __name__ == '__main__':
    main()