P1067 [NOIP2009 普及组] 多项式输出(模拟输出细节)

简介: P1067 [NOIP2009 普及组] 多项式输出(模拟输出细节)

Description of the topic



A dollar nn polyn can be represented by an expression such as:

89473a35ba18106421db8067a9e16343.png

f (x)\a_nx=a_ n-1]x=n-1]]cdos=a_1x=a_0,a_n=n=anxn=an=1xn=1=a=a=a0,=0]


Among them, the a_ix is called the secondary term, a_iai is called the coefficient of the secondary. Given the number and coefficient of a unitary polynomial item, output the polynomial as specified in the following format:


  1. The argument in the polynomial is xx, and the polynomial is given from left to right in decreasing order of number of times.
  2. The polynomial contains only items with a factor of not 00.
  3. If the polyn sub-factor is positive, the polynomial does not begin with a "plus" sign, and if the polyn nn sub-factor is negative, the polynomial begins with a "-".


For items that are not the highest, connect the item with the previous item with a "plus" sign or a "-" sign, indicating that the coefficient is positive or negative, respectively. Follow a positive integer that represents the absolute value of the coefficient (if an item is more than 00 times, the absolute value of the coefficient is 11, no output 11 is required). If the index of xx is greater than 11, the index portion that follows is "x-bxb", where bb is the index of xx, if the index of xx is 11, the index part of the index that follows is "xx", and if the index of xx is 00, only the output coefficient is required.


  1. In a polynomial, there are no extra spaces at the beginning or end of the polynomial.


Enter the format



Input common 2 lines


Line 1 integers,n, representing the number of times a single polynomial.


The second line has an integer of n-plus, where the second integer represents the coefficient of the n-i-1 term, separated by a space between each of the two integers.


The output format



The output totals 1 line, output polynomials in the format described in the title.


A sample of the input and output



Enter #1 copy

1. 5 
2. 100 -1 1 -3 0 10


Output #1 copy

100x^5-x^4+x^3-3x^2+10


Enter #2 copy

1. 3 
2. -50 0 0 1


Output #2 copy

-50x^3+1


Description/Tips



NOIP 2009 Popularization Group First Question

For 100% of the data, 0 sle n sle 1000 ≤n≤100, -100 sle s100 ≤ coefficient sle 100≤100

  #include<bits/stdc++.h>
  using namespace std;
  int main()
  {
    int n,m;
    cin>>n;
    for(int i=n;i>=0;i--)
    {
      cin>>m;
      if(m)//把这个为0的情况直接不输出 
      {if(i!=n&&m>0)cout<<"+";//第一位不能有加号 
      if(abs(m)>1||i==0)cout<<m;//m的绝对值不为1和0; 直接输出m 
      if(m==-1&&i)cout<<"-";// 不是最后 一位,把1删掉 
      if(i>1)cout<<"x^"<<i;
      if(i==1)cout<<"x";//特殊化 
      }
    }
   } 


相关文章
|
存储 小程序 物联网
MQTT常见问题之小程序引用 paho-mqtt失败如何解决
MQTT(Message Queuing Telemetry Transport)是一个轻量级的、基于发布/订阅模式的消息协议,广泛用于物联网(IoT)中设备间的通信。以下是MQTT使用过程中可能遇到的一些常见问题及其答案的汇总:
|
关系型数据库 分布式数据库 数据库
|
机器学习/深度学习 监控 Ubuntu
perf性能分析工具使用分享
perf性能分析工具使用分享
2631 0
perf性能分析工具使用分享
PCIe锁定事务(Locked Transactions)介绍
PCIe锁定事务(Locked Transactions)介绍
1039 0
PCIe锁定事务(Locked Transactions)介绍
|
机器学习/深度学习 计算机视觉 PyTorch
PyTorch 2.2 中文官方教程(四)(3)
PyTorch 2.2 中文官方教程(四)
370 0
PyTorch 2.2 中文官方教程(四)(3)
|
分布式计算 Hadoop
hadoop格式化HDFS的命令
【7月更文挑战第21天】
1207 5
|
XML 网络协议 安全
Nmap的使用
Nmap是一款开源的网络安全扫描工具,用于网络发现和安全审计。它能检测网络上的主机和服务,识别操作系统、开放端口、服务版本,并查找潜在的安全漏洞。Nmap支持多种扫描类型,如主机发现(-sn, -sP等)、端口扫描(-sS, -sT等)、服务和版本探测(-sV)以及操作系统检测(-O)。在使用时,要确保合法性和合规性,避免扫描未经授权的网络。常见参数如 `-oX` 用于输出XML报告,`-A` 选项则进行全面扫描。基础用法包括对单个IP、子网或文件中列出的IP进行扫描。注意,扫描可能消耗大量资源并应适时更新以保证准确性。
316 2
|
SDN 网络虚拟化 网络架构
深入解析网络类型及其特点
【8月更文挑战第24天】
2099 0
|
存储 Java 调度
Nifi 的性能 | 学习笔记
快速学习 Nifi 的性能
508 0
|
存储 网络虚拟化 数据安全/隐私保护
如何在最新版的HCL 5.10.0中导入NFV镜像?
如何在最新版的HCL 5.10.0中导入NFV镜像?