cf703A Mishka and Game】的更多相关文章

A. Mishka and Game time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Mishka is a little polar bear. As known, little bears loves spending their free time playing dice for chocolates. Once in…
题目链接:CF #365 (Div. 2) D - Mishka and Interesting sum 题意:给出n个数和m个询问,(1 ≤ n, m ≤ 1 000 000) ,问在每个区间里所有出现偶数次的数异或的值. 思路:容易想到,把区间内的所有的数都异或得到的是出现奇数次的数的值,然后再异或该区间内的所有出现过的数(每个数只统计一次),得到的ans了. 第一个问题:得到询问区间的所有数的异或值,由 a[1~r] ^ a[0~(l-1)] = a[l~r] 可以用数组all_xor[i…
转载自:http://www.cnblogs.com/icode-girl/p/5744409.html 题目链接:CF #365 (Div. 2) D - Mishka and Interesting sum 题意:给出n个数和m个询问,(1 ≤ n, m ≤ 1 000 000) ,问在每个区间里所有出现偶数次的数异或的值. 思路:容易想到,把区间内的所有的数都异或得到的是出现奇数次的数的值,然后再异或该区间内的所有出现过的数(每个数只统计一次),得到的ans了. 第一个问题:得到询问区间的…
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…
题目链接: http://codeforces.com/contest/703/problem/D D. Mishka and Interesting sum time limit per test 3.5 secondsmemory limit per test 256 megabytes 问题描述 Little Mishka enjoys programming. Since her birthday has just passed, her friends decided to prese…
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…
简单题. #pragma comment(linker, "/STACK:1024000000,1024000000") #include<cstdio> #include<cstring> #include<cmath> #include<algorithm> #include<vector> #include<map> #include<set> #include<queue> #inc…
Mishka and Interesting sum time limit per test 3.5 seconds memory limit per test 256 megabytes input standard input output standard output Little Mishka enjoys programming. Since her birthday has just passed, her friends decided to present her with a…
题目描述 D. Mishka and Interesting sum的意思就是给出一个数组,以及若干询问,每次询问某个区间[L, R]之间所有出现过偶数次的数字的异或和. 这个东西乍看很像是经典问题,一列数字中所有数字出现偶数次,除了一个数字只出现一次,找出那个只出现过一次的数字.然而这个问题并不是要找出现奇数次数字的异或和. 算法 有一个直观的思路是求出[L, R的异或和,再异或上[L, R]之间所有出现过的数字的异或和.这样的话就可以使得数字出现次数的奇偶性发生变化. 那么怎么求出区间[L,…
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…