NOI '17 P1 - Integers

View as PDF

Submit solution

Points: 20 (partial)
Time limit: 2.0s
Memory limit: 512M

Problem type

There is an integer x, initially zero.

There are n operations. Each operation is one of the following types:

  • 1 a b: Add a2b to x where a is an integer (that can be negative) and b is a non-negative integer.
  • 2 k: Write x in binary, and compute the value of the digit corresponding to a weight of 2k.

It is guaranteed that x0 at any time.

Input Specification

The first line of the input consists of four integers, n,t1,t2,t3.

In the following n lines, each line describes an operation.

Two adjacent elements in a line are separated by exactly one space.

Output Specification

For each type 2 k query, output a line with an integer (0 or 1) denoting the answer. There shall be no output for each operation of 1 a b.

Sample Input

Copy
10 3 1 2
1 100 0
1 2333 0
1 -233 0
2 5
2 7
2 15
1 5 15
2 15
1 -1 12
2 15

Sample Output

Copy
0
1
0
1
0

Additional Samples

integer.zip

Constraints

For all test cases, 1t13,1t24,1t32.

Explanation of t1
  • If a test case has t1=1, then a=1.
  • If a test case has t1=2, then |a|=1.
  • If a test case has t1=3, then |a|109.
Explanation of t2
  • If a test case has t2=1, then 0b,k30.
  • If a test case has t2=2, then 0b,k100.
  • If a test case has t2=3, then 0b,kn.
  • If a test case has t2=4, then 0b,k30n.
Explanation of t3
  • If t3=1, then all queries are after updates.
  • If t3=2, then there are no additional constraints.
Test case n t1 t2t3
110312
21002
32000
4400013
5600031
6800022
7900034
8100003
9300004
10500001
116000032
126500024
13700003
14200000
153000002
164000003
175000003
186000004
19700000
208000001
219000002
2293000033
2396000041
2499000032
2510000004

Comments

There are no comments at the moment.