hdu 5344 MZL's xor(数学之异或)
MZL loves xor very much.Now he gets an array A.The length of A is n.He wants to know the xor of all (Ai+Aj)(≤i,j≤n)
The xor of an array B is defined as B1 xor B2...xor Bn
Multiple test cases, the first line contains an integer T(no more than ), indicating the number of cases.
Each test case contains four integers:n,m,z,l
A1=,Ai=(Ai−∗m+z) mod l
≤m,z,l≤∗,n=∗
For every test.print the answer.
找到了规律就好办了,发现对称性,相同的数异或后等于0,所以最后剩下自身*2来异或,注意要用long long
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cmath>
#include<stdlib.h>
#include<map>
using namespace std;
#define ll long long
#define N 600000
ll n,m,z,l;
ll a[N];
int main()
{
int t;
scanf("%d",&t);
while(t--){
scanf("%I64d%I64d%I64d%I64d",&n,&m,&z,&l);
a[]=;
for(int i=;i<=n;i++){
a[i]=(a[i-]*m+z)%l;
}
ll ans=;
for(int i=;i<=n;i++){
ans=ans^(a[i]+a[i]);
}
printf("%I64d\n",ans);
}
return ;
}
hdu 5344 MZL's xor(数学之异或)的更多相关文章
- HDU 5344 MZL's xor (多校)[补7月28]
MZL's xor Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total S ...
- hdu 5344 MZL's xor
MZL's xor Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total S ...
- HDU 5344 MZL's xor (水题)
题意:给一个序列A,设序列B的中的元素有(Ai+Aj)(1≤i,j≤n),那么求B中所有元素的异或之和.而序列A是这样来的:A1=0,Ai=(Ai−1∗m+z) mod l. 思路:相同的元素异或结果 ...
- HDU 5344(MZL's xor-(ai+aj)的异或和)
MZL's xor Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others) Total ...
- hdoj 5344 MZL's xor
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=5344 #include<stdio.h> #include<cstring> ...
- 多校-HDU 5351 MZL's Border 数学规律
f[1] = 'b', f[2] = 'a', f[i] = f[i - 1] + f[i - 2] 斐波那契数列的字符串,给你n和m,前m位中,最长的前缀等于后缀的长度是多少.1≤n≤1000, 1 ...
- hdu5344 MZL's xor(水题)
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud MZL's xor Time Limit: 2000/1000 MS (Java/ ...
- MZL's xor
MZL's xor Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/65536K (Java/Other) Total Sub ...
- HDU 5351 MZL's Border (规律,大数)
[HDU 5351 MZL's Border]题意 定义字符串$f_1=b,f_2=a,f_i=f_{i-1}f_{i-2}$. 对$f_n$的长度为$m$的前缀$s$, 求最大的$k$满足$s[1] ...
随机推荐
- 应用Observer接口实践Observer模式
原文:http://zhangjunhd.blog.51cto.com/113473/68949/ 在Java中通过Observable类和Observer接口实现了观察者模式.Observer对象是 ...
- C# 约瑟夫环算法
using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.T ...
- Spark Accumulators
概述 Accumulator即累加器,与Mapreduce counter的应用场景差不多,都能很好地观察task在运行期间的数据变化,Spark中的Accumulator各task可以对Accumu ...
- 利用dedecms给近三天(或当天)发布的文章显示红色日期或加上new字或new小图片
1)红色日期 <br>[field:pubdate runphp='yes'] <br>$a="<font color=red>".strfti ...
- EnableDocking
CFrameWnd::EnableDocking void EnableDocking(DWORD dwDockStyle); 參数: dwDockStyle 指定框架窗体的哪一边可作为控件条的停靠点 ...
- [AngularJS] Transforming raw JSON data to meaningful output in AngularJS
angular.module('APP', []) .controller('MainController', function($scope, UserConstants){ var user = ...
- SQL函数简述
数字函数ABS 取绝对值 POWER 乘方 LN 10为底数取幂SQRT 平方根 EXP e的n次乘方 LOG(m,n) m为底数n取幂数学运算函数:ACOS ATAN ATAN2 COS COSH ...
- SDWebImage实现原理详解
1)当需要获取网络图片的时候,我们首先需要的便是URL,如果没有URL什么都没有,获得URL后,SDWebImage实现的并不是直接去请求网路,而是检查图片缓存中有没有和URL相关的图片,如果有则直接 ...
- C# 操作NPOI导入导出
//把T_Seats中的输入导出到Excel private void button3_Click(object sender, EventArgs e) { //1.读取 string sql = ...
- zsh-替换掉黑白的控制台
官方地址:里面有详细的安装指南 http://ohmyz.sh/