G - Polynomial Queries

Languages: C, C++, Java, Python, Kotlin, CSharp
Time & Memory limits: (details)

Input

Output

Sample test(s)

Input
5 3 4 2 3 1 7 2 1 5 1 1 5 2 1 5
--- Showing first 30 lines (click "Copy" to get full content) ---
Output
17 32
--- Showing first 30 lines (click "Copy" to get full content) ---