当前位置:网站首页>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
边栏推荐
- How to change the formula picture in the paper directly into the formula in word
- Display the server hard disk image to the browser through Servlet
- The for loop realizes 1-100 addition and eliminates the 4-digit tail number
- JNI uses asan to check memory leaks
- Design and implementation of spark offline development framework
- B_ QuRT_ User_ Guide(38)
- Oracle string sorting
- Markdown
- B_ QuRT_ User_ Guide(39)
- First week of July
猜你喜欢

SAP HR 家庭成员信息

Anxin vb01 offline voice module access intelligent curtain guidance

激光slam学习(2D/3D、偏实践)

Take you hand in hand to build Eureka client with idea

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

【LeetCode】20、有效的括号
![[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](/img/55/ab50ead2564498cb214d98ac5b9c3d.jpg)
[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
![[experiment sharing] log in to Cisco devices through the console port](/img/e4/fc72ed57de74a0dd51c484a1c2f348.png)
[experiment sharing] log in to Cisco devices through the console port

Get started with mongodb

B_ QuRT_ User_ Guide(36)
随机推荐
8.31 Tencent interview
神奇快速幂
SQL database execution problems
C simple question 2
Learn about scratch
一份假Offer如何盗走了「Axie infinity」5.4亿美元?
[untitled]
Open source hardware small project: anxinco esp-c3f control ws2812
What if once again forgets the login password of raspberry pie? And you don't have a monitor yet! Today, I would like to introduce a method
Live-Server使用
【7.5】15. Sum of three numbers
SAP HR 社会工作经历 0023
SAP memory parameter tuning process
MySQL架构
B_ QuRT_ User_ Guide(40)
Understand TCP's three handshakes and four waves with love
gorm 关联关系小结
平衡二叉樹【AVL樹】——插入、删除
USB (XIV) 2022-04-12
关于CH32库函数与STM32库函数的区别


