当前位置:网站首页>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
边栏推荐
- Get started with mongodb
- [untitled]
- Lm12 rolling heikin Ashi double K-line filter
- Download AWS toolkit pycharm
- 进度播报|广州地铁七号线全线29台盾构机全部完成始发
- SAP HR labor contract information 0016
- C method question 1
- Extract the file name under the folder under win
- Open source hardware small project: anxinco esp-c3f control ws2812
- C simple question 2
猜你喜欢

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

Understand TCP's three handshakes and four waves with love

B_QuRT_User_Guide(36)
![Balanced binary tree [AVL tree] - insert, delete](/img/1f/cd38b7c6f00f2b3e85d4560181a9d2.png)
Balanced binary tree [AVL tree] - insert, delete

0-1背包问题
![[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

SAP memory parameter tuning process

MySQL架构

New potential energy of industrial integration, Xiamen station of city chain technology digital summit successfully held

0-1 knapsack problem
随机推荐
SAP HR 劳动合同信息 0016
SAP HR reward and punishment information export
Display the server hard disk image to the browser through Servlet
JNI uses asan to check memory leaks
C number of words, plus ¥, longest word, average value
Class C design questions
Access database query all tables SQL
95.(cesium篇)cesium动态单体化-3D建筑物(楼栋)
B_QuRT_User_Guide(36)
Reverse output three digit and arithmetic sequence
ASP. Net open web page
C - Fibonacci sequence again
507 field D - extraterrestrial relics
The for loop realizes 1-100 addition and eliminates the 4-digit tail number
May day d-light
archery安装测试
B_ QuRT_ User_ Guide(37)
解析token的网址
c—线性表
Download AWS toolkit pycharm


