C. Kuro and Walking Route time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Kuro is living in a country called Uberland, consisting of $$$n$$$ towns, numbered from $$$1$$$ to $$$n$$$, and $$…
C. Kuro and Walking Route time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Kuro is living in a country called Uberland, consisting of nn towns, numbered from 11 to nn, and n−1n−1 bidirectio…
Codeforces 979 D. Kuro and GCD and XOR and SUM 题目大意:有两种操作:①给一个数v,加入数组a中②给出三个数x,k,s:从当前数组a中找出一个数u满足 u与x的gcd可以被k整除,u不大于s-x,且与x的异或和最大. 思路:之前没有碰到过异或和最值的问题,所以是懵逼的.学习了01字典树后把这题补出来. 碰到操作①就上树,上树过程中注意不断维护每个节点往后路径中的最小值(具体见代码细节): 碰到操作②,如果k==1,那么从树上找数的同时注意限制条件最小…
Kuro is living in a country called Uberland, consisting of nn towns, numbered from 11to nn, and n−1n−1 bidirectional roads connecting these towns. It is possible to reach each town from any other. Each road connects two towns aa and bb. Kuro loves wa…
题目链接:http://codeforces.com/contest/979/problem/C Kuro is living in a country called Uberland, consisting of nn towns, numbered from 11 to nn, and n−1n−1 bidirectional roads connecting these towns. It is possible to reach each town from any other. Eac…
Kuro and GCD and XOR and SUM 题意:给你一个空数组. 然后有2个操作, 1是往这个数组里面插入某个值, 2.给你一个x, k, s.要求在数组中找到一个v,使得k|gcd(x,v) (即gcd(x,v)是k的倍数,v+x <= k, x ^ v的值最大. 题解:XOR亦或问题是经典的题目,一般都是用01字典树去处理. 然后需要满足条件1, 所以我们可以对于每一个点建立一个字典树,每次添加数的时候都往这个数的因子添加这个值,这样我们直接访问对应的k就可以找到答案了.…