Maurice Tutor

(5)

$15/per page/Negotiable

About Maurice Tutor

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Algebra,Applied Sciences See all
Algebra,Applied Sciences,Biology,Calculus,Chemistry,Economics,English,Essay writing,Geography,Geology,Health & Medical,Physics,Science Hide all
Teaching Since: May 2017
Last Sign in: 406 Weeks Ago, 2 Days Ago
Questions Answered: 66690
Tutorials Posted: 66688

Education

  • MCS,PHD
    Argosy University/ Phoniex University/
    Nov-2005 - Oct-2011

Experience

  • Professor
    Phoniex University
    Oct-2001 - Nov-2016

Category > Computer Science Posted 17 Sep 2017 My Price 9.00

London Police

Sherlock Holmes has helped the London Police to solve a lot of cases and sent a lot of criminals to prison. But now he is getting bored as there is no interesting case to solve. So he decides to play a game with Watson to spend his time.

Initially he gives him an array of N numbers A1, A2, A3, … An. Now, he asks Watson to tell him the sum of the squares of all numbers in any subarray from Ai to Aj.

i.e. Ai2 + Ai+12 + ...+ Aj2.

To increase the difficulty of the task, he updates the numbers in any subarray from Ai to Aj from time to time. The update is performed in two steps-

1) He multiplies all numbers in the subarray by 2.

2) He divides all multiples of 2048 in the subarray by 2048.

Dr. Watson knows that if he is unable to answer Sherlock’s queries, Sherlock will boast about it for days. So he asks for your help to keep Sherlock’s ego under control.

Input

The first line contains T, the number of test cases.

For each test case, the first line of input contains 2 integers N and Q(number of queries).

Next line contains N integer A1, A2, A3, … An.
Next Q lines contain each defines a query-

0 i j - Sherlock updates all the numbers in the subarray from Ai to Aj as defined above.

1 i j - Watson needs to tell the sum of squares of all numbers in the subarray from Ai to Aj.

Output

For each query of the form 1 i j, output 1 line containing the answer to Sherlock's problem.

Constraints

T

1

1

1

Example

Input: 2 4 3 5 2 1 6 1 2 3 0 1 3 1 2 4 1 3 512 0 1 1 0 1 1 1 1 1 Output: 5 56 1

Answers

(5)
Status NEW Posted 17 Sep 2017 05:09 AM My Price 9.00

Hel-----------lo -----------Sir-----------/Ma-----------dam-----------Tha-----------nk -----------You----------- fo-----------r u-----------sin-----------g o-----------ur -----------web-----------sit-----------e a-----------nd -----------and----------- ac-----------qui-----------sit-----------ion----------- of----------- my----------- po-----------ste-----------d s-----------olu-----------tio-----------n.P-----------lea-----------se -----------pin-----------g m-----------e o-----------n c-----------hat----------- I -----------am -----------onl-----------ine----------- or----------- in-----------box----------- me----------- a -----------mes-----------sag-----------e I----------- wi-----------ll

Not Rated(0)