当前位置:网站首页>P1067 [noip2009 popularity group] polynomial output (difficult, pit)
P1067 [noip2009 popularity group] polynomial output (difficult, pit)
2022-07-07 23:40:00 【Yuesi】
More points to consider
First of all, we must fully understand the meaning of the question
- n Not the number of input data in the second row , But the coefficient of the highest term , The actual number of input data in the second line is n+1 individual ,n Coefficient of secondary term to coefficient of primary term + 1 Constant term
- Judge whether the coefficient is 0
Whether the coefficient is plus or minus one
x To the power of 1 when x The power of is not output , Only the output x
In front of the integer coefficient except the first output number “+” Is it missing
Learn from the code
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
int ans[110];
int x;
int t=0;
int k=0;
scanf("%d",&n);
if(n==0){
scanf("%d",&x);
printf("%d",x);
}else if(n==1){
scanf("%d",&x);
if(x!=0){
if(abs(x)==1){
if(x<0){
printf("-");
}
}else{
printf("%d",x);
}
printf("x");
k++;
}
scanf("%d",&x);
if(x>0){
printf("+");
}
if(x!=0){
k++;
printf("%d",x);
}
if(k==0){
printf("0");
}
}else{
int l=n;
for(int i=1;i<=n-1;i++){
scanf("%d",&ans[i]);
if(ans[i]!=0){
if(t==1){
t=2;
}
if(t==0){
t=1;
}
k++;
if(t==2){
if(ans[i]>0){
printf("+");
}
}
if(ans[i]>1||ans[i]<-1){
printf("%d",ans[i]);
printf("x^%d",l);
}else{
if(ans[i]==-1){
printf("-");
}
printf("x^%d",l);
}
}
l--;
}
scanf("%d",&x);
if(x!=0){
k++;
if(abs(x)==1){
if(x<0){
printf("-");
}
if(x==1){
printf("+");
}
}else{
if(x>0){
printf("+");
}
printf("%d",x);
}
printf("x");
}
scanf("%d",&x);
if(x>0){
printf("+");
}
if(x!=0){
k++;
printf("%d",x);
}
if(k==0){
printf("0");
}
}
return 0;
}
Data points of two sets of cards
99
-1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 -7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 100 1 899
-1 5 -4 -2 1 -5 3 4 -1 4 -5 -5 4 -1 3 2 -1 -2 3 -4 1 1 -5 -2 -1 2 1 -4 -1 -1 -2 -1 5 -3 4 1 2 2 2 -2 -1 3 -1 -2 0 5 -4 -3 -1 3 2 -5 -3 -3 -3 2 0 2 -3 1 5 0 2 -2 0 -3 -3 -3 -5 -4 -4 -3 3 1 1 2 2 -1 0 -5 -4 0 -3 -5 0 -2 -2 -2 4 -1 -1 2 -5 4 1 -5 2 1 4 -3
边栏推荐
- [stm32+esp8266 connects to Tencent cloud IOT development platform 3] stm32+esp8266-01s dynamically registers devices on Tencent cloud (at instruction mode) -- with source code
- Anxin vb01 offline voice module access intelligent curtain guidance
- MySQL Architecture
- 关于CH32库函数与STM32库函数的区别
- USB (XVI) 2022-04-28
- SAP HR 劳动合同信息 0016
- Solution of intelligent supply chain collaboration platform in electronic equipment industry: solve inefficiency and enable digital upgrading of industry
- Enumeration, simulation, and sorting
- The efficient s2b2c e-commerce system helps electronic material enterprises improve their adaptability in this way
- Dataguard 主备清理归档设置
猜你喜欢

SAP HR social work experience 0023

Navicat connects Oracle

ping报错:未知的名称或服务

平衡二叉樹【AVL樹】——插入、删除

Class C design questions

Live server usage

Open source hardware small project: anxinco esp-c3f control ws2812

ASP. Net core middleware request processing pipeline

Learn about scratch

SAP HR reward and punishment information export
随机推荐
B_QuRT_User_Guide(36)
USB (XVII) 2022-04-15
One week learning summary of STL Standard Template Library
Where are you going
First week of July
StringUtils工具类
IDEA 2021.3. X cracking
USB (XV) 2022-04-14
KeePass realizes automatic input of web pages
关于CH32库函数与STM32库函数的区别
[STM32 + esp-12s connect Tencent cloud IOT development platform 1] creation of cloud platform and burning of at firmware
Take you hand in hand to build Eureka client with idea
C - Fibonacci sequence again
SAP 内存参数调优过程
[stm32+esp8266 connects to Tencent cloud IOT development platform 3] stm32+esp8266-01s dynamically registers devices on Tencent cloud (at instruction mode) -- with source code
2022 Season 6 perfect children's model Shaanxi finals came to a successful conclusion
8.31 Tencent interview
Come on, brother
USB (XIV) 2022-04-12
Get started with mongodb


