一看就是找规律的题.只要熟悉异或的性质,可以秒杀. 为了防止忘记异或的规则,可以把异或理解为半加运算:其运算法则相当于不带进位的二进制加法. 一些性质如下: 交换律: 结合律: 恒等律: 归零律: 典型应用:交换a和b的值:a=a^b^(b=a); #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> #include<…
题目链接:http://codeforces.com/contest/424/problem/C, 想来一个小时,就是做不出,都做出来了,悲剧! 分析:我们知道交换异或的顺序不影响答案! 然后就是求t=a1^a2^a3^.....^an;这个直接做可以, q=(1%i)^(2%i)... ^(n^i);(1<=i<=n); //继续写完 当时我的想法是通过找规律,把1-n-1的个数都找出来,但是这个规律找不出. 后来知道有循环节这回事 比如:i=10的时候,循环节是1,2,3,4,..9,如果…
题目 比赛的时候找出规律了,但是找的有点慢了,写代码的时候出了问题,也没交对,还掉分了.... 还是先总结一下位移或的性质吧: 1.  交换律 a ^ b = b ^ a 2. 结合律 (a^b) ^ c = a ^ (b^c) 3. 0^a = a; 4. a^a = 0;    a^a^a = a; 5.   知道a,b,c中任意两个就能推知第三个.      a^b = c 两边同时与a异或得: a ^ (a^b) = a^c 即 0^b = a^c  亦即 b = a^c 四个也是一样…
题目链接 A. Squats time limit per test:1 secondmemory limit per test:256 megabytesinput:standard inputoutput:standard output Pasha has many hamsters and he makes them work out. Today, n hamsters (n is even) came to work out. The hamsters lined up and eac…
http://codeforces.com/contest/510/status/B 题目大意 给一个n*m  找有没有相同字母连起来的矩形串 第一种并查集 瞎搞一下 第一次的时候把val开成字符串了 所以wa 改了AC #include<cstdio> #include<map> //#include<bits/stdc++.h> #include<vector> #include<stack> #include<iostream>…
解题思路是: Q=q1^q2.......^qn = p1^p2......^pn^((1%1)^....(1%n))^((2%1)^......(2%n))^.... 故Q的求解过程分成两部分 第一部分是求p1^p2......^pn 第二部分是求((1%1)^....(1%n))^((2%1)^......(2%n))^.... 将其化成矩形的形式 1%1   1%2  ...........  1%n 2%1   2%2  ............ 2%n ................…
注意题目一次只能改变一个松鼠,Pasha can make some hamster ether sit down or stand up.是单数不是复数 #include <iostream> #include <string> #include <vector> #include <algorithm> #include <cmath> using namespace std; int main(){ int n; cin >>…
按照半径排序,然后累加人数直到超过百万 #include <iostream> #include <algorithm> #include <cmath> #include <cstdio> #include <map> using namespace std; int main(){ int n,s; cin >> n >>s; map<double,int> a; ; i < n ; ++ i){ d…
CF424 A. Squats 题目意思: 有n(n为偶数)个x和X,求最少的变换次数,使得X的个数为n/2,输出变换后的序列. 解题思路: 统计X的个数ans,和n/2比較,少了的话,须要把n/2-ans个x变成X,多了的话须要把ans-n/2个X变成x.(从前往后扫一遍即可了). 代码: //#include<CSpreadSheet.h> #include<iostream> #include<cmath> #include<cstdio> #incl…
C. Vus the Cossack and Strings Vus the Cossack has two binary strings, that is, strings that consist only of "0" and "1". We call these strings aa and bb. It is known that |b|≤|a||b|≤|a|, that is, the length of bb is at most the length…