CodeForces 703B Mishka and trip】的更多相关文章

B. Mishka and trip time limit per test:1 second memory limit per test:256 megabytes input:standard input output:standard output Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she cho…
简单题. 先把环上的贡献都计算好.然后再计算每一个$capital$ $city$额外做出的贡献值. 假设$A$城市为$capital$ $city$,那么$A$城市做出的额外贡献:$A$城市左边城市$L$和右边城市$R$都不能和$A$做出贡献,之前存在的$capital$ $city$和$A$城市不能做出贡献,要注意的是$L$和$R$中存在$capital$ $city$的情况.剩下的城市都可以和$A$做出贡献. #pragma comment(linker, "/STACK:10240000…
Description Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she chose XXX — beautiful, but little-known northern country. Here are some interesting facts about XXX: XXX consists of n …
题目链接: B. Mishka and trip time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, s…
Mishka and trip 题意: 有n个城市,第i个城市与第i+1个城市相连,他们边的权值等于i的美丽度*i+1的美丽度,有k个首都城市,一个首都城市与每个城市都相连,求所有边的权值. 题解: 先把n个城市存下来,之后开一个标记数组,来标记k个首都(这题这块很巧妙,正因为开了标记首都的数组,所以才把O(N^2)的算法降到了O(N)) 把所有城市的美丽值都加起来,遍历首都,每次遍历完就sum-首都,这样,最后求环的剩下的边就好了,环的剩下的边就是i不是首都,i+1也不是首都,那么就i*i+1…
B. Mishka and trip time limit per test 1 second memory limit per test 256 megabytes input  standard input output  standard output  Little Mishka is a great traveller and she visited many countries. After thinking about where to travel this time, she…
F - Mishka and trip Sample Output   Hint In the first sample test: In Peter's first test, there's only one cycle with 1 vertex. First player cannot make a move and loses. In his second test, there's one cycle with 1 vertex and one with 2. No one can…
codeforces 703E Mishka and Divisors 题面 给出大小为\(1000\)的数组和一个数\(k\),求长度最短的一个子序列使得子序列的元素之积是\(k\)的倍数,如果有多个解输出元素和最小的序列. \(k\)和数组元素的数量级都是\(1e12\). 题解 \(f[i][d]\)表示前\(i\)项是\(d\)的倍数的最优解.因为\(d\)只可能是\(k\)的因数,所以离散化一下\(k\)的因数即可. 过程中需要多次求\(gcd\),直接求会超时.需要先预处理\(b[i…
链接 Codeforces 703D Mishka and Interesting sum 题意 求区间内数字出现次数为偶数的数的异或和 思路 区间内直接异或的话得到的是出现次数为奇数的异或和,要得到偶数的需要把区间内出现过的数字不重复的再异或一遍.离线按右端点排序,每次处理一个区间时,如果该数字出现过,则在树状数组中把这个数删去,再重新再该位置加到树状数组中. 代码…
题目:这里 题意:n个城市,每个城市有个魅力值vi,首先,有n条路将这n个城市连成一个环,1号城市连2号城市,2号连3号****n号连1号城市,每条路的魅力值是其连接的两个城市 的魅力值的乘积,这n个城市其中还有k个是特殊城市,每个特殊城市和任意一条城市都有一条路连接,看题目下面的图,保证每两个城市之间最多只有一条路,问所有路的 魅力值之和是多少? 首先是连接成环的路线魅力值,很好算,然后每个特殊城市的路线,先求出所有城市的魅力值之和sum,依次求特殊城市的时候用sum减去这个特殊城市本身以及两…