F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

MZL's xor

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


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 ($A_i$+$A_j$)($1\leq i,j \leq n$)
The xor of an array B is defined as $B_1$ xor $B_2$...xor $B_n$
 

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$
$A_1=0$,$A_i=(A_{i-1}*m+z)$ $mod$ $l$
$1\leq m,z,l \leq 5*10^5$,$n=5*10^5$
 

Output
For every test.print the answer.
 

Sample Input
2 3 5 5 7 6 8 8 9
 

Sample Output
14 16
 

Author
SXYZ
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 11:50:38, Gzip enabled