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


相关文章
|
人工智能 搜索推荐 物联网
InstantID:一张照片,无需训练,秒级个人写真生成
InstantID 是由InstantX项目组推出的一种SOTA的tuning-free方法,只需单个图像即可实现 ID 保留生成,并支持各种下游任务。
|
存储 JavaScript BI
GitHub:GitHub简介、使用方法、经验总结(图文教程)之详细攻略(持续更新!)
GitHub:GitHub简介、使用方法、经验总结(图文教程)之详细攻略(持续更新!)
|
人工智能 关系型数据库 分布式数据库
PolarClaw实战训练营,手把手带你免费部署自己的龙虾
阿里云PolarClaw实战训练营开营!零门槛部署企业级AI智能体“小龙虾”,深度打通PolarDB,聚焦电商场景实战。新用户享免费试用,前10名完成跟练赠定制权益。手把手教学,助你快速上手AI Agent生产力工具。
540 0
|
12月前
|
存储 运维 安全
阿里云出海扶持计划介绍:申请并通过审核可获的最低3500元的出海扶持抵扣金
现在越来越多的中国企业将目光投向国际市场,为了助力这些企业顺利出海,阿里云特别推出了出海扶持计划,为有出海需求的企业提供了一系列专属优惠和全方位支持。其中,购买阿里云海外云服务器申请并通过审核的用户可获得出海扶持抵扣金,即可获得至少3500元、最高可达100万元的上云抵扣金,为企业的出海之路提供云服务的支持。
395 0
|
6月前
|
前端开发 JavaScript API
一个案例教你彻底搞明白`AbortController` 、`AbortSignal`
今天这个案例,最硬核、最扎心、最真相、最干脆、最不墨迹、最不留情面、最一针见血、最开门见山、最单刀直入、最不铺垫、最不客套、最不煽情、最不废话、最不拐弯、最不磨叽、最不装、最不端着、最不啰嗦、最不拖沓、最不委婉、最不掩饰、最不藏着掖着、最直白、最彻底、最决绝、最了当。
315 1
|
Java
try、catch、finally、throw、throws 的用法,finally 块一定会执行吗?举反例说明。
Java异常处理核心关键字包括try、catch、finally、throw、throws。try捕获异常,catch处理异常,finally确保代码执行(通常用于资源释放),throw手动抛出异常,throws声明可能的异常类型。finally块在大多数情况下都会执行,但若JVM终止或线程被强制中断,则可能不执行。
970 5
|
12月前
|
存储 Oracle 关系型数据库
大表在线改造为分区表并释放空间:全流程实战指南
本文介绍大表在线改造为分区表的无锁方案,通过双写迁移、分批同步实现MySQL、Oracle等数据库零停机优化,提升查询性能、释放存储空间,适用于日志表、历史数据表等场景。
|
9月前
|
人工智能 弹性计算 自然语言处理
跨境物流外包后的“管”与“不管”:基于OpenClaw RPA与GEO技术的数字化协同实践
在跨境电商与全球贸易的浪潮下,物流外包已成为企业降低运营成本、提升交付效率的战略选择。然而,许多卖家在将物流业务交付给货运代理(Freight Forwarder)后,往往面临“放手即失控”或“插手反...
|
11月前
|
人工智能 运维 测试技术
2026年阿里云无影AgentBay构建企业版Moltbot(原Clawdbot)部署教程
阿里云无影AgentBay是面向企业级场景的Agent开发与管理平台,集成开发套件、算力调度、权限管控等核心能力,可快速构建适配企业需求的定制化AI代理。2026年,依托无影AgentBay部署企业版Moltbot(原Clawdbot),能实现任务自动化、跨系统协同、数据安全管控等企业级功能,适配办公自动化、研发辅助、客户服务等多场景。本文严格依据官方部署逻辑,拆解从环境准备到功能上线的全流程,全程无营销词汇,确保信息原汁原味、可直接落地。
571 1
|
运维 监控 数据可视化
故障定位48小时→5分钟:靠的不是玄学,是“全网透视眼”
在多云部署的网络架构下,企业需要全方位监控全链路网络,解决故障定位难题。 Fusion WAN可视化平台提供实时监控和故障定位能力,帮助企业实现业务畅通。
故障定位48小时→5分钟:靠的不是玄学,是“全网透视眼”