C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter10: Classes And Data Abstraction
Section: Chapter Questions
Problem 19PE
icon
Related questions
Question

CSE

You are given a sequence of integers A1, A2,..., AN and an integer M.
For any valid integers p, q, let's define F(p,q) as the dot product of the
subsequences Ap, Ap+1, . .., Ap+M–1 and Aq, Aq+1, ..., Aq+M–1, i.e.
F(p, q) = Eo Apti · Aqti-
¬M-1
You should process Q queries. In each query:
• You are given two integers pos and val. Change the value of Apos to val.
• Then, find the sum S = SN-M+1N-M+1
Li=1
Lj=1
F(i, j).
%3D
Develop a python code that prints a single line containing one integer S % 999000000
Sample Input:
321
321
32
Output:
49
Transcribed Image Text:You are given a sequence of integers A1, A2,..., AN and an integer M. For any valid integers p, q, let's define F(p,q) as the dot product of the subsequences Ap, Ap+1, . .., Ap+M–1 and Aq, Aq+1, ..., Aq+M–1, i.e. F(p, q) = Eo Apti · Aqti- ¬M-1 You should process Q queries. In each query: • You are given two integers pos and val. Change the value of Apos to val. • Then, find the sum S = SN-M+1N-M+1 Li=1 Lj=1 F(i, j). %3D Develop a python code that prints a single line containing one integer S % 999000000 Sample Input: 321 321 32 Output: 49
Expert Solution
steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Hyperlinks
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning