寒鸽儿 @ 2019-11-30 22:07:59
诶真的会T?
T了3个点诶
窝寻思着即便是因为python慢的话也不会是局部TLE罢
p_inp = int(input())
res_str = str(2**p_inp - 1)
res_len = len(res_str)
if(res_len > 500):
res_str = res_str[-500:]
else:
res_str = res_str.zfill(500)
print(res_len)
ans = []
for i in range(1, 11, 1):
ans.append(res_str[-50:])
res_str = res_str[:-50]
for i in range(9, -1, -1):
print(ans[i])
by ThreePlusSeven @ 2019-11-30 22:15:36
可能的 PY在某些数据上会被卡的很慢
毕竟py在做这种大数据乘法的速度远不及c++
要是会快速幂可能会好点
by nth_element @ 2019-11-30 23:06:48
@froldH 用pypy好像可以(
by 寒鸽儿 @ 2019-11-30 23:17:37
@nth_element
pypy 3 能多过一个点呢
然鹅似乎只有80 233
by 寒鸽儿 @ 2019-11-30 23:31:57
@ThreePlusSeven 等下窝傻了
竟然没有打快速幂
by 寒鸽儿 @ 2019-12-01 00:50:11
upd: 加了高精度仍然TLE2个点
QaQ
p_inp = int(input())
res_num = 1
at = 2
while p_inp != 0:
if(p_inp % 2 == 1):
res_num = res_num * at
at = at * at
p_inp = p_inp // 2
res_num = res_num - 1
res_str = str(res_num)
res_len = len(res_str)
if(res_len > 500):
res_str = res_str[-500:]
else:
res_str = res_str.zfill(500)
print(res_len)
ans = []
for i in range(1, 11, 1):
ans.append(res_str[-50:])
res_str = res_str[:-50]
for i in range(9, -1, -1):
print(ans[i])
by 寒鸽儿 @ 2019-12-01 00:51:34
似乎python的幂就是用快速幂写的? 手打的快速幂反而慢了