Under construction

Still being built. Things may change

Natural Number Sums

Time limit1sMemory limit1024 MB

Summary
Count sets of distinct integers from 1 to N, none a multiple of K, with an even number of elements that sum to N, modulo 998244353.
Level

Medium6 of 10

Topics
Dynamic programming, Math
Solved
No attempts yet

문제

Two integers NN and KK are given. Find the number of sets SS that satisfy all of the following conditions, modulo 998 244 353998\,244\,353.

  • Every element of SS is a distinct positive integer at most NN that is not a multiple of KK.
  • ∣S∣|S| is even.
  • The sum of all elements of SS is NN.

입력

The first line contains the number of test cases TT.

Each test case is given on one line with two integers NN and KK.

출력

For each test case, print the answer on its own line.

제한

  • 1≤T≤1041 \le T \le 10^{4}
  • 0≤K≤N≤4 0000 \le K \le N \le 4\,000

Examples1

  1. Example 1

    Input
    5
    0 0
    5 0
    6 3
    4 1
    7 7
    
    Expected output
    1
    2
    2
    0
    3