Empty Quartz

시간 제한2초메모리 제한1024 MB

요약
길이 N인 0과 1 문자열 가운데 홀수 합을 갖는 부분배열의 개수가 정확히 K인 것의 수를 998244353으로 나눈 나머지를 여러 질의에 대해 구한다.
난이도

어려움10점 중 8점

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

문제

NN crystals are aligned in a row. However, some of them may be phantoms.

Jun counted the number of real crystals from ll-th to rr-th (closed interval) for every ll, rr (1≤l≤r≤N1 \le l \le r \le N) pair and recorded their evenness.

His N(N+1)2\frac{N(N+1)}{2} records show that there were kk intervals that contained an odd number of real crystals. How many possible crystal alignments are there? Answer the remainder divided by 998244353998244353.

Note that if there is ii such that the ii-th crystal from the left is real on one side and phantom on the other, the two alignments are considered different.

You are given TT of the above problems. Answer each of them.

입력

TT

N_1N\_1 K_1K\_1

⋮\vdots

N_TN\_T K_TK\_T

출력

Output TT lines. On the line ii, answer the problem when N=N_iN = N\_i, K=K_iK = K\_i. Add a new line at the end of each line.

제한

  • All inputs consist of integers.
  • 1≤T≤1051 \le T \le 10^5
  • 1≤N_i≤1051 \le N\_i \le 10^5
  • 0≤K_i≤N_i(N_i+1)20 \le K\_i \le \frac{N\_i(N\_i+1)}{2}

힌트

If we denote a real crystal as 11 and an phantom as 00, the following three alignments satisfy the condition at Sample Input 1.

  • 0,1,00, 1, 0
  • 1,0,11, 0, 1
  • 1,1,11, 1, 1

예제2

  1. 예제 1

    입력
    1
    3 4
    
    예상 출력
    3
    
  2. 예제 2

    입력
    5
    5 9
    6 10
    10 24
    10 25
    100000 75915540
    
    예상 출력
    10
    21
    165
    0
    651081880