P28109 [洛谷] Eternity
提高+
题目描述

Problem Description

Some preliminary definitions:

  • Elements in a multiset must be non-negative integers.
  • The size of a multiset is the number of elements in the multiset.
  • For a multiset of size \( x \), let its elements be \( a_1, a_2, \dots, a_x \). The weight of this multiset is \( a_1 \oplus a_2 \oplus \dots \oplus a_x \), which is the XOR sum of all elements in the multiset.

Given \( n \) and \( m \), the problem asks for the number of distinct multisets \( S \) of size \( n \) such that:

\[ \max_{T \subseteq S, T \ne \emptyset} Q_T = m \]

where \( Q_T \) is the weight of the multiset \( T \).

Note: Due to the nature of multisets, multisets with the same numbers but in different orders are considered the same, i.e., \( \{1, 2, 3\} \) and \( \{3, 2, 1\} \) are considered the same multiset.

Calculate the number of distinct multisets modulo \( 998244353 \).

It can be proven that the number of such multisets is finite.

Input Format

The first line contains two integers, representing \( n \) and \( m \).

Output Format

A single integer representing the answer modulo \( 998244353 \).

Sample Input and Output

Input Sample #1

3 5

Output Sample #1

13

Input Sample #2

12 7

Output Sample #2

48643

Notes

Sample Explanation

For the first sample, the 13 solutions are:

\( (0,0,5) \), \( (0,1,4) \), \( (0,1,5) \), \( (0,4,5) \), \( (0,5,5) \), \( (1,1,4) \), \( (1,1,5) \), \( (1,4,4) \), \( (1,4,5) \), \( (1,5,5) \), \( (4,4,5) \), \( (4,5,5) \), \( (5,5,5) \).

Data Range

Subtask Number \( n \) \( m \) Special Property Score
0 \(\le 10\) \(\le 10\) - 10
1 \(\le 10^5\) \(<2^{60}\) \(A\) 20
2 \(\le 2000\) \(\le 2000\) - 10
3 \(\le 10^5\) \(<2^{60}\) - 60

Special Property \( A \): \(\operatorname{popcount}(m) \le 5\), where \(\operatorname{popcount}(m)\) denotes the number of 1s in the binary representation of \( m \).

For 100% of the data, it is guaranteed that \( 1 \le n \le 10^5 \) and \( 0 \le m < 2^{60} \).

Special Note: This problem uses subtask-based scoring. You must pass all test cases of a subtask to earn the score for that subtask.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
3 5
样例输出
13