[atcoder contest 010] F - Tree Game Time limit : 2sec / Memory limit : 256MB Score : 1600 points Problem Statement There is a tree with N vertices, numbered 1 through N. The i-th of the N−1 edges connects vertices ai and bi. Currently, there are Ai s…
点我看题 A - Max Mod Min 非常诈骗.一开始以为要观察什么神奇的性质,后来发现直接模拟就行了.可以证明总操作次数是\(O(nlog a_i)\)的.具体就是,每次操作都会有一个数a被b取模,然后变成a%b.注意到a%b是\(\leq \frac a2\)的,并且a被操作之后会变成整个数据最小的数,作为下一轮的b.所以把原数组排序后,最小值的位置是不断往左移的,每次移动1个位置,直接模拟即可. 时间复杂度\(O(nlog a_i)\). 点击查看代码 #include <bits/s…