You are on page 1of 2

8/27/2021 Newton School

Newton School PL

Games (Public Contest: August 2021)

standard input/output: 2s/128000 kB

Natasha and Scott are playing a game with a single pile of stones. Initially the pile contains K stones. The players alternate turns, with Natasha starting first. In one move, the
player can either add any odd number of stones to the pile or remove any odd number of stones from the pile. The rules are as follows:

1. The number of stones should not go below 0 or go above N.

2. If at any instance of the game there were x stones, the number of stones cannot be x thereafter.

3. Initially some set of numbers S = {s1, s2, s3, … } are given which are blocked, which means that we are not allowed to play a move after which we will end up with a number of
stones which belongs to this set.

4. The player who cannot move loses.

For a given set S, let F(S) denote the number of K’s (0 ≤ K ≤ N) such that Natasha has a winning strategy for that game. They need you to find ∑ F(S) where summation is over
all the non-empty subsets of {0, 1, 2, ... N}.

back
This number can be very large, so they want you to print it modulo 998244353. 02:11:33 Run Save and Run Hidden Test Cases
Newton's Grand Contest 2021 - Games (Public Contest: August 2021) by Pranav Lad

Input
The file contains multiple test cases. The first line contains an integer T - the number of test cases.
Then T lines follows, each line containing an integer N.

Constraints:

1 ≤ T ≤ 106

1 ≤ N ≤ 106

It is guaranteed that the sum of N over all tests is less than or equal to 106.

Output
Output T lines.

The ith line should contain a single integer, the answer to the ith test case.

Example
16
 
Explanation: 
Test Case 1: N = 1. There are 3 non empty subsets {0}, {1}, {0,1}.
 
a) {0}. Clearly Natasha must start with 0 as only one position, but she cannot make more so sh
b) {1}. Similar to (a).
c) {0,1}. In this case if Natasha start with 0, she can make first move to 1, then Scott does 
 
So total winning positions = 0 + 0 + 2 = 2.

Code Reset Python (3.8.1) Custom Input


1
1 # Your code here

STDOUT STDERR COMPILE OUTPUT MESSAGE


1

Test Cases Previous Submissions

Test case 0 Hidden test case Status Test Cases Passed

Test case 1

Test case 2
Help

Test case 3
https://my.newtonschool.co/playground/code/8j2xn793jta7/ 1/2
8/27/2021 Newton School

Test case 4

Test case 5

Test case 6

Test case 7

Test case 8

Test case 9

Test case 10

Test case 11

Test case 12

Test case 13

© 2021 Incanus Technologies Pvt Ltd


For any queries, you can reach us at Follow us on
All rights reserved. (Terms) support@newtonschool.co

https://my.newtonschool.co/playground/code/8j2xn793jta7/ 2/2

You might also like