作者wheels ()
看板Prob_Solve
标题[问题] KS Round B 2020 Wandering Robot
时间Wed Apr 29 18:03:34 2020
问题在此:https ://ppt.cc/fpuYHx
按照 Analysis 的解法写了以下 Python 3 的 code,
题目的 Sample 都跑得过,但就是 WA,
想请问有什麽地方出错了吗?感谢!
import math
for t in range(1, int(input()) + 1):
W, H, L, U, R, D = map(int, input().split())
p = 0.0
while 0 < L - 1 and D + 1 <= H:
L -= 1
D += 1
exp = math.log2(math.factorial(L + D - 2))
exp -= math.log2(math.factorial(L - 1))
exp -= math.log2(math.factorial(D - 1))
exp -= L + D - 2
p += 2 ** exp
while R + 1 <= W and 0 < U - 1:
U -= 1
R += 1
exp = math.log2(math.factorial(U + R - 2))
exp -= math.log2(math.factorial(U - 1))
exp -= math.log2(math.factorial(R - 1))
exp -= U + R - 2
p += 2 ** exp
print('Case #{}: {}'.format(t, p))
--
※ 发信站: 批踢踢实业坊(ptt.cc), 来自: 114.43.4.111 (台湾)
※ 文章网址: https://webptt.com/cn.aspx?n=bbs/Prob_Solve/M.1588154616.A.BB3.html
※ 编辑: wheels (114.43.4.111 台湾), 04/29/2020 18:03:59
1F:→ wheels: 後来发现原来最後一行和最後一列的算法不一样 lol 04/29 18:20
2F:→ wheels: Analysis 里面提到留给读者自行练习,就被忽略了XD 04/29 18:20