Shil and Square Sum
Practice
3.8 (207 votes)
Approved
Math
Medium
Ready
Problem
91% Success 11293 Attempts 30 Points 1s Time Limit 256MB Memory 1024 KB Max Code
Shil has an array of N elements A1 , A2, ... ,AN . He also has an integer K. He wants to find out value of Square Sum for every i from 1 to N-K+1.
The value of Square Sum for certain i is defined as Σ1≤ j ≤ K (j2 Ai+j-1).
Input:
First line of input consists of two integers N and K. Next line consists of N integers A1 , A2, ... ,AN.
Output:
Output N-K+1 integers where ith integer corresponds to Square Sum of i. Print Square Sum modulus 109+7.
Constraints:
- 1≤ K ≤ N ≤ 106
- 1≤ Ai ≤ 109
Submissions
Please login to view your submissions
Similar Problems
Points:30
17 votes
Tags:
Basic ProgrammingImplementationMedium
Points:30
6 votes
Tags:
AlgorithmsBasic ProgrammingBasics of ImplementationImplementationMedium
Points:30
6 votes
Tags:
Ad-HocMediumStacks
Editorial