MoYi123 最近的时间轴更新
MoYi123

MoYi123

V2EX 第 469223 号会员,加入于 2020-02-14 14:02:50 +08:00
今日活跃度排名 668
MoYi123 最近回复了
@nenseso 成功率还能这么算的? 你是在用纯 udp 协议吗?
专门为你的页面写个接口是没道理的.
可以让后端提供一个能一次性查询多个接口的方法.
大概下面那样.
req
{"data": [{"uri": "get_user", "body": {}}, {"uri": "get_time", "body"}]}
resp
{"data": [{"uri": "get_user", "resp": {"id": "12313"}}, {"uri": "get_time", "resp": "2024-4-29"}]}
“线程池不是应该首先要保证任务完成吗?”

不是, 线程池主要是为了省资源, 减少创建/销毁线程的次数.
你这样做明显会增加创建/销毁线程的次数.
candidates = [10, 20, 20, 30, 40]
target = 45
target1 = 10

from functools import cache

@cache
def dp(idx, count, min_element, max_element):
if idx == len(candidates):
________if count > target and count - min_element < target and count - max_element <= target - target1:
____________print(count, min_element, max_element)
____________return 1
________return 0
____if not count - min_element < target:
________return 0
____ele = candidates[idx]
____pick = dp(idx + 1, count + ele, min(ele, min_element), max(ele, max_element))
____not_pick = dp(idx + 1, count, min_element, max_element)
____return pick + not_pick


print(dp(0, 0, 4e18, 0))


O(n^3 * target) 只有方案数, 具体方案是什么你自己改一下.
要在编译期算运行期的值只能打表啊, 这也没办法.
2 种可能性,
1. 你题目理解错了
2. 面试官 sb
@zero47 这点数量算什么? 随便一个网络游戏, 一次就加载几千个装备物品, 还不是大把人能做?
cache 里不要按调用次数缓存, 改成每秒更新一次就行吧.

还有算 topn 可以用 heap, 虽然这点应该没多大影响.
22 天前
回复了 Curiosity777 创建的主题 Java 请教一个不断增长的数据统计问题
矿是什么东西? 建议不要在问题里加上只有你知道的业务词汇.
然后看了问题, 我也不知道你想要查什么, 怎么查.
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   905 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 15ms · UTC 22:51 · PVG 06:51 · LAX 15:51 · JFK 18:51
Developed with CodeLauncher
♥ Do have faith in what you're doing.