UVA10719Quotient Polynomial
来源:互联网 发布:程序员女神 赵洁琼 编辑:程序博客网 时间:2024/05/21 21:50
UVA-10719
题意:给出p(x)的系数和一个数字k,求一个比p(x)少一次就的q(x),使得p(x)=(x-k)*q(x)+r。
解题思路:用待定系数可以知道,q(x)中 x^n-1 的系数b[n-1] 会等于p(x)中 x^n 的系数a[n]。
然后可以推出-k*b[n-1]+b[n-2] =a[n-1] —-> b[n-2]=a[n-1]+k*b[n-1]。
然后正向存,x^n的系数为a[1],那么对于每个b[i]会有b[i]=a[i]+k*b[i-1];b[n]就是r。
/************************************************************************* > File Name: UVA-10719.cpp > Author: Narsh > > Created Time: 2016年07月15日 星期五 09时38分42秒 ************************************************************************/#include <iostream>#include <algorithm>#include <cstdio>#include <cstring>using namespace std;int a[10060],b[10060],k,n;char c;int main () { while (scanf("%d\n",&k) != EOF) { c=' '; n=0; b[0]=0; while (c != '\n' ) scanf("%d%c",&a[++n],&c); for (int i = 1; i <= n; i++) b[i]=a[i]+k*b[i-1]; printf("q(x):"); for (int i = 1; i < n; i++) printf(" %d",b[i]); printf("\nr = %d\n\n",b[n]); }}
0 0
- UVA10719Quotient Polynomial
- Polynomial
- Polynomial
- Polynomial Time
- C Polynomial
- !!!Polynomial ADT
- Quotient Polynomial
- Quotient Polynomial
- Quotient Polynomial
- Quotient Polynomial
- Quotient Polynomial
- [数据结构]Polynomial
- <OJ_Sicily>Polynomial
- <Sicily>Polynomial
- polynomial regression
- polynomial interpolate
- Polynomial Regression
- 多项式Polynomial
- CC2540/CC2541/CC254x之OSAL消息队列
- UVA-537 Artificial Intelligence?
- nginx负载均衡
- 暑期-dp46道(2)
- spring MVC框架下 前台向java后台传送json字符串数据
- UVA10719Quotient Polynomial
- Android中的ScrollView
- 大素数测试和大数素因子分解
- The MySQL server is running with the --read-only option so it cannot execute this statement
- leetcode——Intersection of Two Arrays II
- 某服务请求经负载均衡设备分配到集群A、B、C、D进行处理响应的概率分别是10%、20%、30%和40%。已知测试集群所得的稳定性指标分别是90%、95%、99%和99.9%。现在该服务器请求处理失败,
- js实现全选和反选功能
- 小心!新媒体环境下,营销传播还有几个大坑!
- unity中鼠标和触摸问题