hdu5344 MZL ' s xor (water problem)

Source: Internet
Author: User

Reprint Please specify source: http://www.cnblogs.com/fraud/--by fraud

MZL ' s XOR

Time limit:2000/1000 MS (java/others) Memory limit:65536/65536 K (java/others)
Total submission (s): 488 Accepted Submission (s): 342


Problem Descriptionmzl loves XOR very much. Now he gets an array a.the length of A are 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  < Span id= "mathjax-span-26" class= "Mrow" > b2 ... xor  b n

Inputmultiple test Cases, the first line contains a integer T (no more than), 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∗5 ,n=5∗5

Outputfor every test.print the answer.

Sample Input23 5 5 76 8 8 9

Sample Output14 16

Two the same number of different or after equals 0, finally only the ai+ai of the difference or value

1 /**2 * Code generated by Jhelper3 * More info:Https://github.com/AlexeyDmitriev/JHelper4 * @author Xyiyy @Https://github.com/xyiyy5  */6 7#include <iostream>8#include <fstream>9 Ten //##################### One //Author:fraud A //Blog:http://www.cnblogs.com/fraud/ - //##################### - //#pragma COMMENT (linker, "/stack:102400000,102400000") the#include <iostream> -#include <sstream> -#include <ios> -#include <iomanip> +#include <functional> -#include <algorithm> +#include <vector> A#include <string> at#include <list> -#include <queue> -#include <deque> -#include <stack> -#include <Set> -#include <map> in#include <cstdio> -#include <cstdlib> to#include <cmath> +#include <cstring> -#include <climits> the#include <cctype> *  $ using namespacestd;Panax Notoginseng #defineRep (X, N) for (int x=0; x<n; X + +) -typedefLong Longll; the  + classhdu5344 { A  Public: the     voidSolve (Std::istream &inch, Std::ostream & out) { +         intT; -         inch>>T; $          while(t--) { $ ll M, Z, L, N; -             inch>> n >> m >> z >>l; -ll x =0; thell ans =0; - Rep (i, N) {WuyiAns ^= (x +x); thex = (x * m + z)%l; -             } Wu              out<< ans <<Endl; -         } About     } $ }; -  -  - intMain () { AStd::ios::sync_with_stdio (false); +Std::cin.tie (0); the hdu5344 solver; -Std::istream &inch(std::cin); $Std::ostream & out(std::cout); theSolver.solve (inch, out); the     return 0; the}

hdu5344 MZL ' s xor (water problem)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.