MoYi123 最近的时间轴更新
MoYi123's repos on GitHub
Python · 10 人关注
mmooyyii
my note
Erlang · 4 人关注
emoji
a emoji dictionary for erlang
Erlang · 4 人关注
trueskill
Erlang implementation of classic TrueSkill and TrueSkill2
Go · 1 人关注
fst
Finite State Transducer
Erlang · 1 人关注
recordis
erlang redis orm
0 人关注
aho-corasick
aho corasick algorithm
Go · 0 人关注
excel_oj
Excel 在线测试平台(大家一起来内卷)
Erlang · 0 人关注
fibheap
Fibonacci heap for erlang
C · 0 人关注
pg_plugin_demo
Go · 0 人关注
practise_db
练习用数据库
Erlang · 0 人关注
ra
A Raft implementation for Erlang and Elixir that strives to be efficient and make it easier to use multiple Raft clusters in a single system.
Erlang · 0 人关注
recon
Collection of functions and scripts to debug Erlang in production.
C · 0 人关注
streamvbyte
Fast integer compression in C using the StreamVByte codec
0 人关注
trueskill-1
Python implementation of TrueSkill player ranking
Go · 0 人关注
WritingAnInterpreterInGo
Writing An Interpreter In Go
Erlang · 0 人关注
x
0 人关注
zheap
new heap with in-place update, powered by undo, for eventual integration into PostgreSQL
MoYi123
ONLINE

MoYi123

V2EX 第 469223 号会员,加入于 2020-02-14 14:02:50 +08:00
今日活跃度排名 602
MoYi123 最近回复了
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) 只有方案数, 具体方案是什么你自己改一下.
23 小时 51 分钟前
回复了 GeruzoniAnsasu 创建的主题 C++ 最近发现的 C++ 笑话: switch(a){ case 1: return 1;}
要在编译期算运行期的值只能打表啊, 这也没办法.
23 小时 57 分钟前
回复了 nulIptr 创建的主题 程序员 面试见闻,关于一个简单题目的算法和复杂度的讨论
2 种可能性,
1. 你题目理解错了
2. 面试官 sb
@zero47 这点数量算什么? 随便一个网络游戏, 一次就加载几千个装备物品, 还不是大把人能做?
cache 里不要按调用次数缓存, 改成每秒更新一次就行吧.

还有算 topn 可以用 heap, 虽然这点应该没多大影响.
15 天前
回复了 Curiosity777 创建的主题 Java 请教一个不断增长的数据统计问题
矿是什么东西? 建议不要在问题里加上只有你知道的业务词汇.
然后看了问题, 我也不知道你想要查什么, 怎么查.
带懒删除的 fib heap
21 天前
回复了 zdking08135 创建的主题 程序员 请教一个系统设计题
只要想办法把 Euler Tour Tree 存数据库里就行了.
dijkstra 关于这个写过文章, 可以看看.
https://www.cs.utexas.edu/users/EWD/transcriptions/EWD08xx/EWD831.html
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   5254 人在线   最高记录 6543   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 15ms · UTC 08:00 · PVG 16:00 · LAX 01:00 · JFK 04:00
Developed with CodeLauncher
♥ Do have faith in what you're doing.