• 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 }
  • 相关阅读:
    Redis是可以安装成windows服务-开机自启 win7 64位
    lnmp 一键安装包 nginx配置tp5 phpinfo模式 隐藏index.php
    Redis PHP通用类
    Swoole2.0协程客户端连接池的实现
    Tomcat 部署项目无法加载静态资源
    IntelliJ IDEA 的下载和安装
    Redis 配置内容总结
    Eclipse 中 Spring 项目的 XML 配置文件报错 Referenced file contains errors
    Eclipse 中 Maven 项目 pom.xml 提示错误 org.codehaus.plexus.archiver.jar.Manifest.write(java.io.PrintWriter)
    文本编辑器 EditPlus 的激活与设置
  • 原文地址:https://www.cnblogs.com/fraud/p/4705805.html
Copyright © 2020-2023  润新知