当前位置:网站首页>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
边栏推荐
- Reverse output three digit and arithmetic sequence
- SAP HR奖罚信息导出
- Extract the file name under the folder under win
- [summary] some panels and videos seen
- 【7.5】15. Sum of three numbers
- [experiment sharing] log in to Cisco devices through the console port
- B_ QuRT_ User_ Guide(37)
- Class C design questions
- Balanced binary tree [AVL tree] - insert, delete
- List. How to achieve ascending and descending sort() 2020.8.6
猜你喜欢
ASP. Net core middleware request processing pipeline
SAP HR social work experience 0023
KeePass realizes automatic input of web pages
SAP 内存参数调优过程
List. How to achieve ascending and descending sort() 2020.8.6
Take you hand in hand to build Eureka client with idea
Anxinco esp32-a1s development board is adapted to Baidu dueros routine to realize online voice function
[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
C cat and dog
Lm12 rolling heikin Ashi double K-line filter
随机推荐
Given an array, such as [7864, 284, 347, 7732, 8498], now you need to splice the numbers in the array to return the "largest possible number."
Installing gradle
C simple question 2
95.(cesium篇)cesium动态单体化-3D建筑物(楼栋)
SAP 内存参数调优过程
[untitled]
受限线性表
Flash encryption process and implementation of esp32
Get started with mongodb
Have all the fresh students of 2022 found jobs? Is it OK to be we media?
USB (XVI) 2022-04-28
JNI uses asan to check memory leaks
【7.4】25. K 个一组翻转链表
@Configuration注解的详细介绍
ESP at installation esp8266 and esp32 versions
USB (XV) 2022-04-14
Pycharm essential plug-in, change the background (self use, continuous update) | CSDN creation punch in
Take you hand in hand to build Eureka server with idea
Summary of common methods of object class (September 14, 2020)
C - Fibonacci sequence again