我解决了MORECAKE的问题。(点击这里查看问题) 问题来自PCO12020大赛,但我在正确输出方面遇到了问题,我试了很多方法,但每次都显示WA。代码每次都给出正确的INT值。我只是需要帮助输出,请问。输出顺序也是正确的。我也试过放'/n',并使输出为标签式。
这是我的代码。
任何帮助将是感激的,我刚刚开始竞争编码,请帮助。
#Username: chefteerth ## https://www.codechef.com/users/chefteerth
#Question URL: https://www.codechef.com/PCO12020/problems/MORECAKE
# Problem Name: More Cake
# Problem Code: MORECAKE
# Programming Lang: Python3
test = int(input())
lst_sum = []
ans_list = []
p = 0
while p < test:
i = 0
llist = []
TotalSlice, TotalMember, Smallest, R= map(int,input().split(" "))
llist.append(Smallest)
while TotalMember-1 > i:
new_val = Smallest * R
Smallest = new_val
llist.append(new_val)
i = i + 1
if sum(llist) - TotalSlice <= 0:
poss = "POSSIBLE" + str(TotalSlice - sum(llist))
ans_list.insert(p, poss)
else:
poss = "IMPOSSIBLE" + str(abs(TotalSlice - sum(llist)))
ans_list.insert(p, poss)
lst_sum.append(sum(llist))
p = p+1
for k in range(len(ans_list)):
print(ans_list[k])
if sum(lst_sum) >= 0:
print("POSSIBLE")
else:
print("IMPOSSIBLE")