CF1603F.October 18, 2017
省选/NOI-
通过率:0%
时间限制:4.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
It was October 18, 2017. Shohag, a melancholic soul, made a strong determination that he will pursue Competitive Programming seriously, by heart, because he found it fascinating. Fast forward to 4 years, he is happy that he took this road. He is now creating a contest on Codeforces. He found an astounding problem but has no idea how to solve this. Help him to solve the final problem of the round.
You are given three integers n, k and x. Find the number, modulo 998244353, of integer sequences a1,a2,…,an such that the following conditions are satisfied:
- 0≤ai<2k for each integer i from 1 to n.
- There is no non-empty subsequence in a such that the bitwise XOR of the elements of the subsequence is x.
A sequence b is a subsequence of a sequence c if b can be obtained from c by deletion of several (possibly, zero or all) elements.
时间是2017年10月18日。肖哈格——一个忧郁的灵魂——下定决心,要全心全意地投身于算法竞赛编程,因为他发现这门学科令人着迷。时光飞逝,转眼已过四年,他为自己当初选择这条道路而感到欣慰。如今,他正在 Codeforces 上举办一场比赛。他发现了一道令人惊叹的题目,却毫无解题思路。请帮助他解决本轮比赛的最后一题。
给定三个整数 n、k 和 x。求满足以下条件的整数序列 a1,a2,…,an 的个数(对 998244353 取模):
- 对每个 i=1,2,…,n,均有 0≤ai<2k;
- 序列 a 中不存在任何非空子序列,使得该子序列中所有元素的按位异或(XOR)结果等于 x。
若序列 b 可通过从序列 c 中删除若干(可能为零个或全部)元素得到,则称 b 是 c 的一个子序列。
输入格式
The first line contains a single integer t (1≤t≤105) — the number of test cases.
The first and only line of each test case contains three space-separated integers n, k, and x (1≤n≤109, 0≤k≤107, 0≤x<2min(20,k)).
It is guaranteed that the sum of k over all test cases does not exceed 5⋅107.
第一行包含一个整数 t(1≤t≤105)—— 表示测试用例的数量。
每个测试用例仅有一行,包含三个以空格分隔的整数 n、k 和 x(1≤n≤109,0≤k≤107,0≤x<2min(20,k))。
保证所有测试用例中 k 的总和不超过 5⋅107。
输出格式
For each test case, print a single integer — the answer to the problem.
对于每个测试用例,输出一个整数——即该问题的答案。
输入输出样例
输入#1
6 2 2 0 2 1 1 3 2 3 69 69 69 2017 10 18 5 7 0
输出#1
6 1 15 699496932 892852568 713939942
说明/提示
In the first test case, the valid sequences are [1,2], [1,3], [2,1], [2,3], [3,1] and [3,2].
In the second test case, the only valid sequence is [0,0].
在第一个测试用例中,合法的序列有 [1,2]、[1,3]、[2,1]、[2,3]、[3,1] 和 [3,2]。
在第二个测试用例中,唯一合法的序列是 [0,0]。
输入解题思路,AI测评打分。不知道怎么写?