A. 【UR #17】滑稽树上滑稽果

本文针对一条特殊数据链的问题进行了解析,通过分析发现每次操作都能使值减少至少一位1,进而提出了一种枚举最高位并递归查找的解决策略。此外,还介绍了一种动态规划方法,通过状态转移方程优化了求解过程。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

题解:

首先很显然的是这是一条链(特殊数据说是链是故意让人迷茫的??)

然后 自己就开始yy 觉得每一次是加入一个使得当前值最小的数

然而这tm又是特殊数据??

那就写一波发现是错的

考虑一下特殊数据的1e5

我们会发现每一次and一下减少至少一个1(或者从此之后保持不变)

这样我们可以枚举这一次的最高位

在剩余的数中寻找是否有这一位为0的 递归下去就可以了

时间是nloga的

再考虑一般情况

显然我们可以设f[i][s]表示前i个,状态为s

转移就是枚举ai,有一个小问题就是 ai会被重复用

但其实想一下就会发现 ai若是重复用 对于s是不会改变的 等于在浪费

很容易可以yy的就是 当这个数没有到达所有数and的和时,一定有数能让他变小

另外i显然是没用的状态可以去掉了

这样时间是na的

dp的瓶颈在转移处

 其实很简单 我们可以考虑枚举它的子集 判断这个是否是合法的

假如判断是O(1)的 那这个就是n^(log2_3)的

如何做到判断O(1)呢?

我们预处理出f[i]表示该状态可以由哪个最小的ai得到 转移就是f[i]------->f[i&(1<<j)] 是n*位数的

转载于:https://www.cnblogs.com/yinwuxiao/p/8647412.html

# # collect interval interval = 15 [[instances]] # # append some labels for series # labels = { region="cloud", product="n9e" } # # interval = global.interval * interval_times # interval_times = 1 ## Docker Endpoint ## To use TCP, set endpoint = "tcp://[ip]:[port]" ## To use environment variables (ie, docker-machine), set endpoint = "ENV" # endpoint = "unix:///var/run/docker.sock" endpoint = "unix:///var/run/docker.sock" labeled_containers = true ## Set to true to collect Swarm metrics(desired_replicas, running_replicas) gather_services = false gather_extend_memstats = false container_id_label_enable = true container_id_label_short_style = true ## Containers to include and exclude. Globs accepted. ## Note that an empty array for both will include all containers container_name_include = [] container_name_exclude = [] ## Container states to include and exclude. Globs accepted. ## When empty only containers in the "running" state will be captured. ## example: container_state_include = ["created", "restarting", "running", "removing", "paused", "exited", "dead"] ## example: container_state_exclude = ["created", "restarting", "running", "removing", "paused", "exited", "dead"] # container_state_include = [] # container_state_exclude = [] ## Timeout for docker list, info, and stats commands timeout = "5s" ## Specifies for which classes a per-device metric should be issued ## Possible values are &#39;cpu&#39; (cpu0, cpu1, ...), &#39;blkio&#39; (8:0, 8:1, ...) and &#39;network&#39; (eth0, eth1, ...) ## Please note that this setting has no effect if &#39;perdevice&#39; is set to &#39;true&#39; perdevice_include = [] ## Specifies for which classes a total metric should be issued. Total is an aggregated of the &#39;perdevice&#39; values. ## Possible values are &#39;cpu&#39;, &#39;blkio&#39; and &#39;network&#39; ## Total &#39;cpu&#39; is reported directly by Docker daemon, and &#39;network&#39; and &#39;blkio&#39; totals are aggregated by this plugin. ## Please note that this setting has no effect if &#39;total&#39; is set to &#39;false&#39; total_include = ["cpu", "blkio", "network"] ## Which environment variables should we use as a tag ##tag_env = ["JAVA_HOME", "HEAP_SIZE"] ## docker labels to include and exclude as tags. Globs accepted. ## Note that an empty array for both will include all labels as tags docker_label_include = [] docker_label_exclude = ["annotation*", "io.kubernetes*", "*description*", "*maintainer*", "*hash", "*author*", "*org_*", "*date*", "*ur l*", "*docker_compose*"] ## Optional TLS Config # use_tls = false # tls_ca = "/etc/categraf/ca.pem" # tls_cert = "/etc/categraf/cert.pem" # tls_key = "/etc/categraf/key.pem" ## Use TLS but skip chain & host verification # insecure_skip_verify = false
最新发布
03-13
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值