Binary Modulo <P2SME>
Practice
5 (1 votes)
Data structures
Medium
Segment trees
Problem
34% Success 658 Attempts 30 Points 5s Time Limit 256MB Memory 1024 KB Max Code

You are given a Binary String A of length N indexed from 0 to \(N-1\). You have to perform 2 queries:-

  1. 0 L R - Tell the remainder of Number(in \(Decimal\)) represented by the Binary String between indexes L and R when divided by 5.
  2. 1 X V - Replace character at position X with V.

INPUT FORMAT
First line contains T which denotes the number of test cases.
The first line of each test case contains the binary string A.
The next line contains Q which is the number of queries.
Next Q lines contain the description of queries which may be of either of the 2 types as described in the problem statement.

OUTPUT FORMAT
For each query of Type 0, print the answer in a single line.

CONSTRAINTS

  • \(1 ≤ T ≤ 100\)
  • \(1 ≤ N,Q ≤ 10^{4}\)
  • \(0 ≤ L ≤ R < N\)
  • \(0 ≤ X < N\)
  • \(0 ≤ V ≤ 1\)


Hints for using the inbuilt code snippet
Let us take the example of sample input. So your function should return the output such that it resembles "0" + "\n" + "3" + "\n" + "2" + "\n" so that it correctly matches the output format as asked. You can use other alternatives too but the output format as rendered by the print function should match the format of sample out.


Note: It is not mandatory to use the code snippet that is provided to you in the editor by default. It is just to make the question more convenient. You can completely remove the default code and submit your solution in the appropriate format.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
8 votes
Tags:
ApprovedMathMediumOpenTrees
Points:30
114 votes
Tags:
ApprovedData StructuresDynamic ProgrammingFenwick TreeHiringMediumReadySegment Trees
Points:30
12 votes
Tags:
Data StructuresMediumSegment TreesTrees