K. Let the Flames Begin 题目链接:https://codeforces.com/gym/101955/problem/K 题意: n个人围成一个圈,然后依次从1开始报数,报到k的人出局,现在有个人,他想要成为第m个出局的男人,现在要求他初始位置应该在哪. 题解: 类似于约瑟夫环问题,所以我们可以考虑一下递推.我们可以考虑一下n和n - 1规模的关系,借助于约瑟夫环的思路,我们可以知道,如果一个人在n - 1规模时位置为p,那么n的规模时位置应为(p + k) % n (下…
Little boxes on the hillside. Little boxes made of ticky-tacky. Little boxes. Little boxes. Little boxes all the same. There are a green boxes, and b pink boxes. And c blue boxes and d yellow boxes. And they are all made out of ticky-tacky. And they…
A triangle is a Heron’s triangle if it satisfies that the side lengths of it are consecutive integers t−1, t, t+ 1 and thatits area is an integer. Now, for given n you need to find a Heron’s triangle associated with the smallest t bigger than or equa…
Day 1: 早上6点起床打车去车站,似乎好久没有这么早起床过了,困到不行,在火车上睡啊睡就睡到了南京.南航离南京南站很近,地铁一站就到了,在学校里看到了体验坐直升机的活动,感觉很强.报道完之后去吃了一波食堂,感觉南航食堂装修非常有情调,饭菜种类也很多,打菜的小哥很热情,看到我们用的是20元的饭票但没凑够20块,还送了饮料. 下午热身赛前没事干,给jsb传授了一些玩植物大战僵尸2的经验.热身赛的体验并不很好,机器很卡,没有我们平时习惯用的gedit,写代码的时候保存一下就会卡一会儿,一开始PC2…
题目链接: 题意:有 n 个人围成一个圈,从 1 开始报到第 k 个人出环,问第 m 个出环的人是谁,n.m.k <= 1e18 且 min(m,k)<= 2e6. 题解:容易得出O(m)的递推公式 f[n][m] = (f[n-1][m-1] + k - 1)% n + 1,初始状态 f[n-m+1][1]容易得出,当 m 小的时候用该公式计算.考虑 k 大 m 小的情况下,递推式的取膜很多情况下没有用到,可以用乘法代替加法加速递推的过程: 当前状态为f[a][b] = c, 经过 x 次加…
Here N (N ≥ 3) rabbits are playing by the river. They are playing on a number line, each occupying a different integer. In a single move, one of the outer rabbits jumps into a space between any other two. At no point may two rabbits occupy the same p…
Consider a un-rooted tree T which is not the biological significance of tree or plant, but a tree as an undirected graph in graph theory with n nodes, labelled from 1 to n. If you cannot understand the concept of a tree here, please omit this problem…
The ant Welly now dedicates himself to urban infrastructure. He came to the kingdom of numbers and solicited an audience with the king. He recounted how he had built a happy path in the kingdom of happiness. The king affirmed Welly’s talent and hoped…
Then n - 1n−1 lines follow. ii-th line contains two integers f_{a_i}(1 \le f_{a_i} < i)fai(1≤fai<i), w_i(0 \le w_i \le 10^{18})wi(0≤wi≤1018) —The parent of the ii-th node and the edge weight between the ii-th node and f_{a_i} (ifai(istart fr…
Miku is matchless in the world!” As everyone knows, Nakano Miku is interested in Japanese generals, so Fuutaro always plays a kind of card game about generals with her. In this game, the players pick up cards with generals, but some generals have con…