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: 398 Weeks Ago, 3 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 8.00

pairwise product sum

Mr. Singh recently had a breakup with his girlfriend. Depressed, Mr. Singh decides to do what he loves - coding. But he is not able to solve the problem he got his hands on

 

which frustrates him even more. You are a friend of Mr. Singh and decide to help him solve the problem described below.

 

Given N non negative numbers, the task is to answer M queries.

 

Each query is as follows:

 

Given u,v you need to find the pairwise product sum (u and v are zero indexed)

 

auau + au+1au+1 + au+1au + au+2au

 

+2 + au+2au+1 + au+2au + ... + avav +

 

avav-1 + ... + avau

 

 

Input

 

  • The first line of the input contains an integer N denoting the number of elements.
  • Next line contains N space separated integers
  • Next line contains a single integer M denoting number of queries.
  • Next M lines contain two integers u and v as described above.

 

Output

 

  • For each query,print the answer as described above in a new line.

 

Constraints

 

  • 1 = N = 100000
  • 1 = M = 100000
  • 0 = u,v = N-1
  • 0 = ai = 100

 

Example

Input: 5 2 0 1 3 3 2 0 2 1 2 Output: 7 1

Answers

(5)
Status NEW Posted 17 Sep 2017 12:09 PM My Price 8.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)