ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#212544 | #3839. 小t爱算数(mul) | 18550161685 | 10 | 0ms | 1224kb | C++ | 1.4kb | 2024-10-19 11:05:35 | 2024-10-19 12:34:50 |
answer
#include<bits/stdc++.h>
using namespace std;
long long a[1005],b[1005],n;
long long c[1005],d[1005],m;
long long x[1005],y[1005],ansn;
long long pd[1005];
signed main(){
long long xx=0;
while(1){
if(n%2==1){
b[n/2+1]=xx;
}
else{
a[n/2]=xx;
}
n++;
cin>>xx;
if(xx==-1 && n%2==1){
break;
}
}
xx=0;
while(1){
if(m%2==1){
d[m/2+1]=xx;
}
else{
c[m/2]=xx;
}
m++;
cin>>xx;
if(xx==-1 && m%2==1){
break;
}
}
n--;
m--;
n/=2;
m/=2;
for(long long i=1;i<=n;i++){
for(long long j=1;j<=m;j++){
ansn++;
x[ansn]=a[i]*c[j];
y[ansn]=b[i]+d[j];
}
}
for(long long i=1;i<=ansn;i++){
for(long long j=1;j<=ansn;j++){
if(y[i]>y[j]){
swap(y[i],y[j]);
swap(x[i],x[j]);
}
}
}
for(long long i=2;i<=ansn;i++){
if(y[i]==y[i-1]){
y[i-1]=0;
x[i]+=x[i-1];
x[i-1]=0;
pd[i-1]=1;
}
}
long long firstt=0;
for(long long i=1;i<=ansn;i++){
if(pd[i]==0){
if(y[i]==0){
if(firstt==0){
cout<<x[i];
firstt=1;
}
else if(x[i]<0){
cout<<x[i];
}
else{
cout<<"+"<<x[i];
}
}
else if(firstt==0){
cout<<x[i]<<"x^"<<y[i];
firstt=1;
}
else{
if(x[i]<0){
cout<<x[i]<<"x^"<<y[i];
}
else{
cout<<"+"<<x[i]<<"x^"<<y[i];
}
}
}
}
return 0;
}
详细
小提示:点击横条可展开更详细的信息
Test #1:
score: 10
Accepted
time: 0ms
memory: 1224kb
input:
10 -7 9 3 7 4 6 -3 4 2 3 -7 2 -7 0 -3 -1 10 -9 8 9 7 -6 6 7 5 -2 3 -9 2 -9 1 7 0 3 -1
output:
63x^20-27x^19-63x^18+33x^17-40x^16+71x^15-75x^14+172x^13+88x^12-145x^11-16x^10-11x^9-7x^8+5x^7+15x^6...
result:
ok single line: '63x^20-27x^19-63x^18+33x^17-40...146x^5+20x^4-43x^3+6x^2-21x^1-9'
Test #2:
score: 0
Wrong Answer
time: 0ms
memory: 1220kb
input:
4 3 2 -2 -1 4 3 2 2 -1
output:
9x^8+0x^6-4x^4
result:
wrong answer 1st lines differ - expected: '9x^8-4x^4', found: '9x^8+0x^6-4x^4'
Test #3:
score: 0
Runtime Error
input:
100 -7 99 73 98 30 97 44 96 -23 95 -40 94 92 93 -87 92 -27 91 40 90 -3 89 -9 88 -60 87 99 86 -16 85 ...
output:
result:
Test #4:
score: 0
Runtime Error
input:
1000 -807 999 73 998 930 997 544 996 -923 995 -440 994 492 993 -987 992 -327 991 840 990 -303 989 -7...
output:
result:
Test #5:
score: 0
Runtime Error
input:
1000 -807 999 73 998 930 997 544 996 -923 995 -440 994 492 993 -987 992 -327 991 840 990 -303 989 -7...
output:
result:
Test #6:
score: 0
Runtime Error
input:
1000 -807 999 73 998 930 997 544 996 -923 995 -440 994 492 993 -987 992 -327 991 840 990 -303 989 -7...
output:
result:
Test #7:
score: 0
Wrong Answer
time: 0ms
memory: 1216kb
input:
3 1 2 -1 0 1 -1 1 1 -1
output:
1x^4-1x^3+1x^1
result:
wrong answer 1st lines differ - expected: 'x^4-x^3+x^1', found: '1x^4-1x^3+1x^1'
Test #8:
score: 0
Runtime Error
input:
999 -807 998 73 997 930 996 544 995 -923 994 -440 993 492 992 -987 991 -327 990 840 989 -303 988 -70...
output:
result:
Test #9:
score: 0
Runtime Error
input:
0 -807 1 73 2 930 3 544 4 -923 5 -440 6 492 7 -987 8 -327 9 840 10 -303 11 -709 12 -560 13 99 14 -81...
output:
result:
Test #10:
score: 0
Runtime Error
input:
0 -807 1 73 2 930 3 544 4 -923 5 -440 6 492 7 -987 8 -327 9 840 10 -303 11 -709 12 -560 13 99 14 -81...