d = {} for range(2)中的i:对于_ in range(int(input())):p,c = map(int,input()。split()。split())d [p] = d.get(p,0) + c output =''对于分类(d.keys(),反向= true):如果d [pwr]:如果d [pwr] <0:output + =' - ' - 'else:output +=' +'如果abs(d [pwr])!= 1:output += str(abs(d [pwr]))elif not pwr:output +='1'如果pwr:output +='x'如果pwr!= 1:输出 +='^' +str(pwr)如果输出:print(output.lstrip(' +'))else:print(0)
注释
发表评论