2015多校 #5 1002 MZL's xor

MZL‘s xor

Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 1509    Accepted Submission(s): 619

Problem Description

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)(1≤i,j≤n)
The xor of an array B is defined as B1 xor B2...xor Bn

Input

Multiple test cases, the first line contains an integer T(no more than 20), indicating the number of cases.
Each test case contains four integers:n,m,z,l
A1=0,Ai=(Ai−1∗m+z) mod l
1≤m,z,l≤5∗105,n=5∗105

Output

For every test.print the answer.

Sample Input

2
3 5 5 7
6 8 8 9

Sample Output

14
16

水题

两个相等的数异或为0

先用它给的公式算出 a[1..n]来

然后 答案就是(2倍的a[i] )的异或。。。

/*************************************************************************
    > File Name: code/multi/#5/1002.cpp
    > Author: 111qqz
    > Email: [email protected]
    > Created Time: 2015年08月04日 星期二 13时51分14秒
 ************************************************************************/

#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<map>
#include<set>
#include<queue>
#include<vector>
#include<stack>
#define y0 abc111qqz
#define y1 hust111qqz
#define yn hez111qqz
#define j1 cute111qqz
#define tm crazy111qqz
#define lr dying111qqz
using namespace std;
#define REP(i, n) for (int i=0;i<int(n);++i)
typedef long long LL;
typedef unsigned long long ULL;
const int inf = 0x7fffffff;
const int N=5E5+7;
LL a[N];
LL ans;
int n,m,z,l;
int main()
{
    int T;
    cin>>T;
    while (T--)
    {
    scanf("%d %d %d %d",&n,&m,&z,&l);
    a[1] = 0;
    for ( int i = 2; i <= n ; i++ )
    {
        a[i] = (a[i-1]*m+z)%l;
    }

    ans = 0;
    for ( int i = 1 ;i <= n;  i++ )
    {
        ans = ans ^ (a[i]+a[i]);
    }
    printf("%lld\n",ans);
    }

    return 0;
}

2015多校 #5 1002 MZL's xor

时间: 2024-10-13 18:53:12

2015多校 #5 1002 MZL's xor的相关文章

hdu5348(2015多校5)--MZL&#39;s endless loop(搜索)

题目链接:点击打开链接 题目大意:给出n个点,m条无向边,现在要求将无向边变为有向边,要保证每个点的出度和入度的差不超过1 直接进行搜索,对每个点进行出度和入度的判断,如果出度大,就先进行反向的搜索(每搜索一条边u,v就认为这是一条v到u的有向边),反之,进行正向搜索(每搜到一条边u,v认为这是一条u到v的有向边),一直搜索到找不到边能继续为止. 注意: 1.已经使用过的边为了防止再次被遍历,可以修改head,head[u] = edge[i].next 2.注意自环,因为搜索是判断能不能继续向

hdu5351(2015多校5)--MZL&#39;s Border(打表,,找规律)

题目链接:点击打开链接 题目大意:给出b1 = 'b' , b2 = 'a' , bi = b(i-1)b(i-2),将i-1和i-2链接起来,记录一个串的s[1-i] 和s[n-i+1-n]相同的话 Border,当i为最长是为LBorder,现在给让求在bn这个串上的前m个字符组成的子串的LBorder 通过计算可以发现,b字符串的前缀都是相同的,所以只要求出m的LBorder就行,和n是无关的,打表找出规律,找出对应不同的m,LBorder的值,因为存在大数,用java写 dp[i]第i层

2015 多校 #5 1005 MZL&#39;s chemistry

MZL's chemistry Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1306    Accepted Submission(s): 601 Problem Description MZL define F(X) as the first ionization energy of the chemical element X N

2015 多校 #5 1007 MZL&#39;s simple problem

MZL's simple problem Time Limit: 3000/1500 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 2541    Accepted Submission(s): 694 Problem Description A simple problemProblem DescriptionYou have a multiple set,and now th

2015 多校赛 1002 (hdu 5289)

Description Tom owns a company and he is the boss. There are n staffs which are numbered from 1 to n in this company, and every staff has a ability. Now, Tom is going to assign a special task to some staffs who were in the same group. In a group, the

HDU 5344(2015多校5)-MZL&#39;s xor(水题)

题目地址:HDU 5344 题意:求所有(Ai+Aj)的异或值. 思路:可以发现(Ai+Aj)和(Aj+Ai)的异或值为0,所以最后只剩下(Ai+Ai). #include <stdio.h> #include <math.h> #include <string.h> #include <stdlib.h> #include <iostream> #include <sstream> #include <algorithm>

HDU 5344 MZL&#39;s xor (多校)[补7月28]

MZL's xor Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 249    Accepted Submission(s): 187 Problem Description MZL loves xor very much.Now he gets an array A.The length of A is n.He wants to k

hdu5289||2015多校联合第一场1002贪心+RMQ

http://acm.hdu.edu.cn/showproblem.php?pid=5289 Problem Description Tom owns a company and he is the boss. There are n staffs which are numbered from 1 to n in this company, and every staff has a ability. Now, Tom is going to assign a special task to

hdu 5344 (多校联赛) MZL&#39;s xor --- 位运算

here:    首先看一下题吧:题意就是让你把一个序列里所有的(Ai+Aj) 的异或求出来.(1<=i,j<=n) Problem Description 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)(1≤i,j≤n) The xor of an array B is defined as B1 xor B2...xor B