Computer Science Question

icon
Related questions
Question

Computer Science Question

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, İ.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 = N-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, İ.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 = N-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