A polynomial of degree n can be expressed as
p(x)=anxn+an−1xn−1+⋅⋅⋅+a1x+a0p(x) = a_nx^n + a_{n−1}x^{n−1} + · · · + a_1x + a_0p(x)=an​xn+an−1​xn−1+⋅⋅⋅+a1​x+a0​
    If k is any integer then we can write:
p(x)=(x−k)q(x)+rp(x) = (x − k)q(x) + rp(x)=(x−k)q(x)+r
    Here q(x) is called the quotient polynomial of p(x) of degree (n − 1) and r is any integer which is called the remainder.
    For example, if p(x)=x3−7x2+15x−8p(x) = x^3 − 7x^2 + 15x − 8p(x)=x3−7x2+15x−8 and k = 3 then q(x)=x2−4x+3q(x) = x^2 − 4x + 3q(x)=x2−4x+3 and r = 1. Again if
p(x)=x3−7x2+15x−9p(x) = x^3 − 7x^2 + 15x − 9p(x)=x3−7x2+15x−9 and k = 3 then q(x)=x2−4x+3q(x) = x^2 − 4x + 3q(x)=x2−4x+3 and r = 0.
    In this problem you have to find the quotient polynomial q(x) and the remainder r. All the input and output data will fit in 32-bit signed integer.
Input
Your program should accept an even number of lines of text. Each pair of line will represent one test case. The first line will contain an integer value for k. The second line will contain a list of integers (an,an−1,...,a0a_n, a_{n−1}, . . . , a_0an​,an−1​,...,a0​), which represent the set of co-efficient of a polynomial p(x). Here 1 ≤ n ≤ 10000. Input is terminated by <EOF>.
Output
For each pair of lines, your program should print exactly two lines. The first line should contain the coefficients of the quotient polynomial. Print the reminder in second line. There is a blank space before and after the ‘=’ sign. Print a blank line after the output of each test case. For exact format, follow the given sample.
Sample Input
3
1 -7 15 -8
3
1 -7 15 -9
Sample Output
q(x): 1 -4 3
r = 1

q(x): 1 -4 3
r = 0

问题链接:UVA10719 Quotient Polynomial
问题简述:(略)
问题分析:多项式系数计算问题,不解释。
程序说明:(略)
参考链接:(略)
题记:(略)

AC的C++语言程序如下:

/* UVA10719 Quotient Polynomial */#include <bits/stdc++.h>using namespace std;const int N = 10000 + 1;
int a[N], b[N];int main()
{int n;while (scanf("%d", &n) == 1) {char c;int cnt = 0;do {scanf("%d", &a[cnt++]);} while ((c = getchar()) != '\n');b[1] = a[0];for (int i = 2; i <= cnt; i++)b[i] = a[i - 1] + n * b[i - 1];printf("q(x): ");for (int i = 1; i < cnt - 1; i++)printf("%d ", b[i]);printf("%d\n", b[cnt - 1]);printf("r = %d\n\n", a[cnt - 1] + n * b[cnt - 1]);}return 0;
}

UVA10719 Quotient Polynomial【多项式】相关推荐

  1. virtual hust 2013.6.23 数学杂题基础题目 M - Quotient Polynomial

    题目:Quotient Polynomial 思路:水题,就是感觉对输入有点措手不及,捡起来以前大一的时候用的读取到回车退出了. 然后就是多项式分解. #include <cstring> ...

  2. 2019牛客多校 第七场 B Irreducible Polynomial 多项式因式分解判断

    链接:https://ac.nowcoder.com/acm/contest/887/B 来源:牛客网 Irreducible Polynomial 时间限制:C/C++ 1秒,其他语言2秒 空间限制 ...

  3. AOAPC I: Beginning Algorithm Contests 题解

    AOAPC I: Beginning Algorithm Contests 题解 AOAPC I: Beginning Algorithm Contests (Rujia Liu) - Virtual ...

  4. CTF-CRYPTO-RSA Polynomial

    CTF-CRYPTO-RSA Polynomial RSA Polynomial 题目分析 开始 1.题目 2.分析 (1)分解N (2)欧拉函数 (3)提取多项式的参数 3.上脚本 4.get fl ...

  5. 【学习笔记】超简单的多项式开方

    整理的算法模板合集: ACM模板 目录 P5205 [模板]多项式开根 点我看多项式全家桶(●^◡_◡◡​^●) P5205 [模板]多项式开根 #include <cstdio> #in ...

  6. 数据结构课程设计---实现一元稀疏多项式计算器

    课程设计课题: 设计一个一元稀疏多项式简单计算器,能够实现五大基本功能: (1)输入并建立多项式: (2)输出多项式,输出形式为整数序列:n,c1,e1,c2,e2,-,cn,en,其中n是多项式的项 ...

  7. c++实现多项式类定义

    c++实现多项式类的定义,可进行+.-.*.赋值运算,可显示已存储几个多项式对象,可计算任意x值下多项式的值. //****************************************** ...

  8. 双变量polynomial commitment

    1. 引言 本博文主要研究的是 Benedikt Bünz 等人(standford,ethereum,berkeley) 2019年论文<Proofs for Inner Pairing Pr ...

  9. 基于Java实现的一元稀疏多项式计算器

    资源下载地址:https://download.csdn.net/download/sheziqiong/85896976 资源下载地址:https://download.csdn.net/downl ...

最新文章

  1. android 自定义view文字不齐,Android 解决TextView排版参差不齐的问题
  2. 代码环复杂度的计算公式
  3. C语言九十三之输入一个字符x,找到输入的那句话(字符串)里面一样字母的位置。
  4. 【LeetCode】3月29日打卡-Day14-BFS
  5. java复制一个对象_Java中对象的复制
  6. DBA/运维人员近期直播活动日历
  7. 给C#的oracle绿色版
  8. android serviceconnection unbind流程,Android Service 再次 unbindSrvice 时的问题
  9. Centos6.x 64位 安装JDK
  10. 洛谷p3392计算机教育新社会,洛谷-P3392 涂国旗
  11. 如何下载衡水市卫星地图高清版大图
  12. android word分页,word文档如何设置分页以及取消分页
  13. 2022年Cs231n PPT笔记-训练CNN
  14. Android 在一个APP内打开另一个APP
  15. IDear 创建web项目
  16. 如何在报表控件FastReport.NET中连接XLSX 文件作为数据源?
  17. 终于还是对闲鱼下手了。闲鱼爬虫,idlefish spider来了
  18. 一行命令,瞬间从“马赛克”到高清影像!
  19. 科林明伦杯 哈尔滨理工大学第十届程序设计竞赛 (补)
  20. 如何提高孩子专注力?

热门文章

  1. 解决IP地址冲突的方法--DHCP SNOOPING
  2. Kubernetes Service详解(概念、原理、流量分析、代码)
  3. Starling中文站开发教程
  4. dao generator for php and mysql_mybatis generator 自动生成dao层映射代码
  5. android 小米截图,小米工程师晒基于Android Q定制的MIUI截图
  6. 关于Android Studio Arctic Fox版本找不到Database Inspection这件事
  7. 人工智能之入门大数据
  8. java一览删除一条数据_可以删除单条数据,不能再返回列表页面,我使用的是Spring MVC...
  9. dnf上海2服务器维护,DNF上海2出现大面积盗号并迅速蔓延请注意
  10. java数据库实体层封装_Java通过JDBC封装通用DAO层