UVA 10719 (暑假-数学(3) - C - Quotient Polynomial)

#include <cstdio>
const int MAX = 10050;

int main() {
	int k;
	while (scanf("%d", &k) != EOF) {
		int arr[MAX], brr[MAX]; 
		int i = 0;
		char c;
		while (scanf("%d%c", &arr[i], &c) && c != '\n') { 
			if (i != 0)
				brr[i] = arr[i] + k * brr[i - 1];
			else
				brr[i] = arr[i];
			i++;
		}

		printf("q(x):");
		int j = 0;
		while (j < i) {
			printf(" %d", brr[j++]);
		}
		printf("\nr = %d\n\n", arr[j] + k * brr[j-1]);
	}
	return 0;
}

你可能感兴趣的:(UVA 10719 (暑假-数学(3) - C - Quotient Polynomial))