poj3495 Bitwise XOR of Arithmetic Progression
来源:互联网 发布:天刀阿暖捏脸数据 编辑:程序博客网 时间:2024/06/05 10:18
因为异或运算看成可以每一位单独单独做加法运算,也就是求
不妨写成更一般的形式,求
首先把
对于后面这个东西,不妨记
斜率就是
于是我们惊喜地发现,斜率和截距的分母一样,因此变成了和原来问题形式相同的问题。而且原来的整数对
#include<cstdio>#include<algorithm>using namespace std;#define LL long longLL solve(LL n,LL a,LL b,LL c){ if (c==0) return 0; return a/c*n*(n-1)/2+b/c*n+solve((a%c*n+b%c)/c,c,(a*n+b)%c,a%c)&1;}int main(){ LL x,y,z,n,ans; while (scanf("%lld%lld%lld",&x,&y,&z)==3) { ans=0; n=(y-x)/z; for (int i=0;i<32;i++) ans|=solve(n+1,z,x,1LL<<i)<<i; printf("%lld\n",ans); }}
1 0
- poj3495 Bitwise XOR of Arithmetic Progression
- poj 3495 Bitwise XOR of Arithmetic Progression
- POJ 3495 Bitwise XOR of Arithmetic Progression 数论
- POJ 3495 Bitwise XOR of Arithmetic Progression 数论
- ARITHMETIC PROGRESSION
- Arithmetic Progression
- Arithmetic Progression
- Arithmetic Progression
- [第一次训练]Arithmetic Progression
- Arithmetic Progression解题报告
- USACO: Arithmetic Progression
- Arithmetic Progression CodeForces
- C. Arithmetic Progression
- C. Arithmetic Progression
- Codeforces 382 C. Arithmetic Progression
- USACO 1.4.1 Arithmetic Progression
- codeforces#382C. Arithmetic Progression
- C. Arithmetic Progression----细节题
- (ssl1010)P1004 2000年分区联赛提高组之四 方格取数
- 威佐夫博弈
- android的安装
- CCF NOI1074 2的幂次方表示
- linux获取U盘可用空间大小,U盘大小——statfs的使用
- poj3495 Bitwise XOR of Arithmetic Progression
- 一个activity两个fragment的通信
- pandas学习笔记-DataFrame(1)
- 模式识别之(一)SVM的opencv3.0实现
- tmk吃汤饭
- GPA HDU 4802
- 【Java】Java中的swap
- 凑平方数
- 如何在非Activity类中,跳转到另外一个Activity类(context.startActivity(intent); )