QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 16 MB Puntuación total: 10

#11670. Polynomial 2

Estadísticas

For a given polynomial $W$ and a given number $x$, determine the last three digits (the hundreds, tens, and units digits) of the value of the expression $W(x)$.

Task

Write a program that:

  • reads the description of the polynomial $W$ and the number $x$,
  • determines the last three digits of the value of the expression $W(x)$,
  • prints the result.

Input

The first line contains two integers $s$ ($1 \le s \le 20\,000$) and $x$ ($-1\,000\,000 \le x \le 1\,000\,000$). The second line contains $s$ integers $w_1, w_2, \ldots, w_s$ ($-1\,000\,000 \le w_k \le 1\,000\,000$), separated by single spaces. These numbers are the successive coefficients of the polynomial: $W(x) = w_1x^{s-1} + w_2x^{s-2}+\ldots+w_{s-1}x+w_s$.

Output

Your program should print a string consisting of the last three digits of the number equal to the value of the expression $W(x)$, in the order from the hundreds digit to the units digit.

Examples

Input 1

3 2
5 6 7

Output 1

039

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.