hdu5344 MZL's xor(水题)

转载请注明出处: 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 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)(1i,jn)
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=(Ai1m+z) mod l
1m,z,l5105,n=5105
 

 

Output
For every test.print the answer.
 

 

Sample Input
2 3 5 5 7 6 8 8 9
 

 

Sample Output
14 16

 两个相同的数异或之后等于0,最终只剩下Ai+Ai的异或值

 1 /**
 2  * code generated by JHelper
 3  * More info: https://github.com/AlexeyDmitriev/JHelper
 4  * @author xyiyy @https://github.com/xyiyy
 5  */
 6 
 7 #include <iostream>
 8 #include <fstream>
 9 
10 //#####################
11 //Author:fraud
12 //Blog: http://www.cnblogs.com/fraud/
13 //#####################
14 //#pragma comment(linker, "/STACK:102400000,102400000")
15 #include <iostream>
16 #include <sstream>
17 #include <ios>
18 #include <iomanip>
19 #include <functional>
20 #include <algorithm>
21 #include <vector>
22 #include <string>
23 #include <list>
24 #include <queue>
25 #include <deque>
26 #include <stack>
27 #include <set>
28 #include <map>
29 #include <cstdio>
30 #include <cstdlib>
31 #include <cmath>
32 #include <cstring>
33 #include <climits>
34 #include <cctype>
35 
36 using namespace std;
37 #define rep(X, N) for(int X=0;X<N;X++)
38 typedef long long ll;
39 
40 class hdu5344 {
41 public:
42     void solve(std::istream &in, std::ostream &out) {
43         int t;
44         in >> t;
45         while (t--) {
46             ll m, z, l, n;
47             in >> n >> m >> z >> l;
48             ll x = 0;
49             ll ans = 0;
50             rep(i, n) {
51                 ans ^= (x + x);
52                 x = (x * m + z) % l;
53             }
54             out << ans << endl;
55         }
56     }
57 };
58 
59 
60 int main() {
61     std::ios::sync_with_stdio(false);
62     std::cin.tie(0);
63     hdu5344 solver;
64     std::istream &in(std::cin);
65     std::ostream &out(std::cout);
66     solver.solve(in, out);
67     return 0;
68 }

 

 

转载于:https://www.cnblogs.com/fraud/p/4705805.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值