CF 15C
来源:互联网 发布:航迹规划 算法 编辑:程序博客网 时间:2024/06/05 17:02
题意:给出n组xi,mi, 代表有n组数,x,x+1…x+m-1
求这所有数的^值
由于从1和从2开始连续异或值有规律。
1=1
1^2=3
1^2^3=0
1^2^3^4=4
1^2^3^4^5=1
…
四组一循环的规律..
然后就是 ^的性质了,相同为0,那么S(x-1)^ S(x+m-1)=x^x+1^…..^x+m-1的值了
#include <cstdio>#include <algorithm>#include <iostream>using namespace std;typedef long long ll;ll s(ll x){ ll t=x&3; if(t==1)return 1; else if(t==2)return x+1; else if(!t)return x; else return 0;}int main(){ int t;scanf("%d",&t);ll ans=0; while(t--) { ll x,m;scanf("%lld%lld",&x,&m); ans^=s(x-1)^s(x+m-1); } ans?puts("tolik"):puts("bolik");}
0 0
- CF 15C
- Cf Edu 15 C Cellular Network 二分
- CF Educational Codeforces Round 15(C)
- CF 190C STL
- CF 79C. Beaver
- CF 229C Triangles
- CF 4 C
- cf 230c
- CF 255C
- CF 27C
- CF 52C
- CF 190C
- CF 191 div2 C
- CF 143 div2 C
- CF-div2-192-C
- cf 100 c(greedy)
- CF 188 (div2 C)
- cf-337C Quiz
- 数据库查询重复记录的数量
- error creating bean with name 'XXXXXX' defined......
- ASP.NET 首页性能的十大做法
- 利用pyinstaller将python3程序打包为exe文件
- java中的类方法和实例方法
- CF 15C
- 用python写个死锁
- UVA - 301 Transportation
- 美团推荐算法实战
- UVA - 10344 23 out of 5
- java基础总结
- UVA - 331 Mapping the Swaps
- iOS-GCD中dispatch source使用
- 剑指Offer_06 根据前序遍历和中序遍历序列 重建二叉树