UVA10586 POJ2527 Polynomial Remains数学
Posted 海岛Blog
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了UVA10586 POJ2527 Polynomial Remains数学相关的知识,希望对你有一定的参考价值。
Polynomial Remains
Time Limit: 1000MS Memory Limit: 65536K
Total Submissions: 1451 Accepted: 816
Description
Given the polynomial
a(x) = an x^n + … + a1 x + a0,
compute the remainder r(x) when a(x) is divided by x^k+1.
Input
The input consists of a number of cases. The first line of each case specifies the two integers n and k (0 <= n, k <= 10000). The next n+1 integers give the coefficients of a(x), starting from a0 and ending with an. The input is terminated if n = k = -1.
Output
For each case, output the coefficients of the remainder on one line, starting from the constant coefficient r0. If the remainder is 0, print only the constant coefficient. Otherwise, print only the first d+1 coefficients for a remainder of degree d. Separate the coefficients by a single space.
You may assume that the coefficients of the remainder can be represented by 32-bit integers.
Sample Input
5 2
6 3 3 2 0 1
5 2
0 0 3 2 0 1
4 1
1 4 1 1 1
6 3
2 3 -3 4 1 0 1
1 0
5 1
0 0
7
3 5
1 2 3 4
-1 -1
Sample Output
3 2
-3 -1
-2
-1 2 -3
0
0
1 2 3 4
Source
Alberta Collegiate Programming Contest 2003.10.18
问题链接:UVA10586 POJ2527 Polynomial Remains
问题简述:给定n和k,有一个一元n次方程,由0次幂开始给定系数。用这个式子去除以x^k+1,求剩下的一元n-k次方程。
问题分析:数学问题,用模拟法来解决,不解释。
程序说明:(略)
参考链接:(略)
题记:(略)
AC的C++语言程序如下:
/* UVA10586 POJ2527 Polynomial Remains */
#include <iostream>
#include <cstdio>
using namespace std;
const int N = 10000;
int n, k, a[N + 1];
int main()
{
while (~scanf("%d%d", &n, &k) && (n != -1 || k != -1)) {
for (int i = n; i >= 0; i--) scanf("%d", &a[i]);
for (int i = 0; i <= n - k; i++)
a[i + k] -= a[i], a[i] = 0;
int i = 0;
while (a[i] == 0 && i <= n) i++;
if (i > n) printf("0");
for (int j = n; j >= i; j--) {
if (j != n) putchar(' ');
printf("%d", a[j]);
}
putchar('\\n');
}
return 0;
}
以上是关于UVA10586 POJ2527 Polynomial Remains数学的主要内容,如果未能解决你的问题,请参考以下文章
2018 Spring Single Training B (uva 572,HihoCoder 1632,POJ 2387,POJ 2236,UVA 10054,HDU 2141)
POJ 1015 / UVA 323 Jury Compromise(01背包,打印路径)