Alleys Construction

시간 제한1초메모리 제한2048 MB

요약
원 위에 놓인 n개의 집을 서로 교차하지 않는 선으로 짝지어 연결하는 방법의 수를 313109로 나눈 나머지를 구한다.
난이도

보통10점 중 7점

유형
조합론, 동적 계획법, 정수론, 수학
정답자
아직 제출이 없습니다

문제

In Andrei's city, people want to socialize as much as possible after the pandemic. The Fund for Providing the City (FPC) has announced that they want to construct alleys to create small social bubbles between households. An alley is a connection between two distinct houses. Each house must be connected with exactly one alley to another house within the same neighbourhood and the alleys may not intersect. Moreover, we know that the number of inhabitants of any neighbourhood will be even and the houses in each neighbourhood are arranged in a circle. The inhabitants want to find out, for each neighbourhood, in how many ways these alleys can be built. For example, in a neighbourhood that has six houses, there are five possible ways of constructing alleys, as shown in Figure A.1.

Figure A.1: For a neighbourhood of six houses, there are five possible ways of constructing alleys. Each black dot represents a house, and each line represents a possible alley.

Calculate in how many possible ways the inhabitants of Andrei's city could construct alleys in each neighbourhood. Because this number can be very high, the answer should be modulo 313109313109.

입력

The input consists of:

  • A line with a single integer qq (1≤q≤1041\leq q\leq 10^4), the number of neighbourhoods.
  • qq lines, each containing one even number nn (2≤n≤10182\leq n\leq 10^{18}), representing the number of the houses in the neighbourhood.

출력

Output qq lines, each line containing one number: the number of possible ways in which alleys can be built in each neighbourhood. This number should be modulo 313109313109.

예제1

  1. 예제 1

    입력
    4
    6
    10
    122
    50
    
    예상 출력
    5
    42
    256789
    182049