UVA10268 498-bis多项式
Posted 海岛Blog
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了UVA10268 498-bis多项式相关的知识,希望对你有一定的参考价值。
Looking throw the “Online Judge’s Problem Set Archive” I found a very interesting problem number 498, titled “Polly the Polynomial”. Frankly speaking, I did not solve it, but I derived from it this problem.
Everything in this problem is a derivative of something from 498. In particular, 498 was “… designed to help you remember … basic algebra skills, make the world a better place, etc., etc.”. This problem is designed to help you remember basic derivation algebra skills, increase the speed in which world becomes a better place, etc., etc.
In 498 you had to evaluate the values of polynomial
a
0
x
n
+
a
1
x
n
−
1
+
.
.
.
+
a
n
−
1
x
+
a
n
.
a_0x^n + a_1x^{n−1} + . . . + a_{n−1}x + a_n.
a0xn+a1xn−1+...+an−1x+an.
In this problem you should evaluate its derivative. Remember that derivative is defined as
a
0
n
x
n
−
1
+
a
1
(
n
−
1
)
x
n
−
2
+
.
.
.
+
a
n
−
1
.
a_0nx^{n−1} + a_1(n − 1)x^{n−2} + . . . + a_{n−1}.
a0nxn−1+a1(n−1)xn−2+...+an−1.
All the input and output data will fit into integer, i.e. its absolute value will be less than 231.
Input
Your program should accept an even number of lines of text. Each pair of lines will represent one problem. The first line will contain one integer - a value for x. The second line will contain a list of integers a0, a1, …, an−1, an, which represent a set of polynomial coefficients.
Input is terminated by ¡EOF¿.
Output
For each pair of lines, your program should evaluate the derivative of polynomial for the given value x and output it in a single line.
Sample Input
7
1 -1
2
1 1 1
Sample Output
1
5
问题链接:UVA10268 498-bis
问题简述:(略)
问题分析:多项式问题,不解释。
程序说明:(略)
参考链接:(略)
题记:(略)
AC的C++语言程序如下:
/* UVA10268 498-bis */
#include <bits/stdc++.h>
using namespace std;
int main()
{
int x;
while (scanf("%d", &x) == 1) {
char c;
getchar();
c = getchar();
int sum = 0, ans = 0, a;
while (c != '\\n' && c != EOF) {
if (c == '-' || isdigit(c)) {
ungetc(c, stdin);
scanf("%d", &a);
ans = ans * x + sum;
sum = sum * x + a;
}
c = getchar();
}
printf("%d\\n", ans);
}
return 0;
}
以上是关于UVA10268 498-bis多项式的主要内容,如果未能解决你的问题,请参考以下文章
UVA 10951 - Polynomial GCD(数论)
UVa 817 According to Bartjens 题解
UVA10719 Quotient Polynomial多项式
uva live 7639 Extreme XOR Sum (暴力+二项式)
UVA326 LA5434 POJ1538 Extrapolation Using a Difference Table二项式