zoukankan      html  css  js  c++  java
  • 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 }
  • 相关阅读:
    判断两个数组是否相等
    IIS应用程序池性能分析
    配置Windows Update,补丁更新
    正则表达式从右往左进行匹配(Regex)
    OpenSSL
    openssl用法详解
    OpenSSL生成公钥私钥***
    HTTP认证与https简介
    单机至亿级流量大型网站系统架构的演进过程
    程序员常用英语词汇
  • 原文地址:https://www.cnblogs.com/fraud/p/4705805.html
Copyright © 2011-2022 走看看