题目链接:uva 10586 - Polynomial Remains
题目大意:给出一个n和k,表示有一个一元n次方程,有0次幂开始给出系数,用这个式子去除以x^k+1,求剩下的一元n-k次方程。
解题思路:模拟除的过程即可,注意k < n的情况.
#include <stdio.h> #include <string.h> #include <algorithm> using namespace std; const int N = 10005; int n, k, a[N]; int main () { while (scanf("%d%d", &n, &k) == 2 && n != -1 && k != -1) { for (int i = n; i >= 0; i--) scanf("%d", &a[i]); int t = max(n - k, -1); for (int i = 0; i <= t; i++) a[i+k] -= a[i]; printf("%d", a[n]); for (int i = n - 1; i > t; i--) printf(" %d", a[i]); printf("\n"); } return 0; }
Google_codejam2014_Problem A: Magic Trick,布布扣,bubuko.com
Google_codejam2014_Problem A: Magic Trick
原文:http://blog.csdn.net/buxizhizhou530/article/details/23605071