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";//特殊化 
      }
    }
   } 


相关文章
|
8月前
|
移动开发
【机组】算术逻辑单元带进位运算实验的解密与实战
【机组】算术逻辑单元带进位运算实验的解密与实战
117 0
技术好文共享:辅助角公式的几何意义
技术好文共享:辅助角公式的几何意义
|
Cloud Native Go 开发工具
如何让CSDN学习成就个人能力六边形全是100分:解析个人能力雷达图的窍门
如何让CSDN学习成就个人能力六边形全是100分:解析个人能力雷达图的窍门
329 0
Matlab:如何利用层次分析法(升级版)计算具有多重指标的判断矩阵的一致性检验和权重
Matlab:如何利用层次分析法(升级版)计算具有多重指标的判断矩阵的一致性检验和权重
386 0
|
机器学习/深度学习 传感器 算法
改进海洋捕食者算法NMPA 可直接运行 提供23个基准函数对比与秩和检验 注释详细适合新手小白~Matlab
改进海洋捕食者算法NMPA 可直接运行 提供23个基准函数对比与秩和检验 注释详细适合新手小白~Matlab
P1308 [NOIP2011 普及组] 统计单词数(模拟加函数+数学分析)
P1308 [NOIP2011 普及组] 统计单词数(模拟加函数+数学分析)
84 0
P1098 [NOIP2007 提高组] 字符串的展开(模拟分析能力)
P1098 [NOIP2007 提高组] 字符串的展开(模拟分析能力)
109 0
|
算法 测试技术
算法强化每日一题--倒置字符串
算法强化每日一题--倒置字符串
|
机器学习/深度学习 iOS开发 Windows
P2671 [NOIP2015 普及组] 求和(前缀和)
P2671 [NOIP2015 普及组] 求和(前缀和)
149 0
KMP算法细节详解(带动图理解)(2)
KMP算法细节详解(带动图理解)(2)

热门文章

最新文章