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
The xor of an array B is defined as B1 xor B2...xor Bn
Each test case contains four integers:n,m,z,l
A1=0,Ai=(Ai−1∗m+z) mod l
1≤m,z,l≤5∗105,n=5∗105
3 5 5 7
6 8 8 9
两个相同的数异或之后等于0,最终只剩下Ai+Ai的异或值
- /**
- * code generated by JHelper
- * More info: https://github.com/AlexeyDmitriev/JHelper
- * @author xyiyy @https://github.com/xyiyy
- */
- #include <iostream>
- #include <fstream>
- //#####################
- //Author:fraud
- //Blog: http://www.cnblogs.com/fraud/
- //#####################
- //#pragma comment(linker, "/STACK:102400000,102400000")
- #include <iostream>
- #include <sstream>
- #include <ios>
- #include <iomanip>
- #include <functional>
- #include <algorithm>
- #include <vector>
- #include <string>
- #include <list>
- #include <queue>
- #include <deque>
- #include <stack>
- #include <set>
- #include <map>
- #include <cstdio>
- #include <cstdlib>
- #include <cmath>
- #include <cstring>
- #include <climits>
- #include <cctype>
- using namespace std;
- #define rep(X, N) for(int X=0;X<N;X++)
- typedef long long ll;
- class hdu5344 {
- public:
- void solve(std::istream &in, std::ostream &out) {
- int t;
- in >> t;
- while (t--) {
- ll m, z, l, n;
- in >> n >> m >> z >> l;
- ll x = ;
- ll ans = ;
- rep(i, n) {
- ans ^= (x + x);
- x = (x * m + z) % l;
- }
- out << ans << endl;
- }
- }
- };
- int main() {
- std::ios::sync_with_stdio(false);
- std::cin.tie();
- hdu5344 solver;
- std::istream &in(std::cin);
- std::ostream &out(std::cout);
- solver.solve(in, out);
- return ;
- }
hdu5344 MZL's xor(水题)的更多相关文章
- HDU 5344 MZL's xor (水题)
题意:给一个序列A,设序列B的中的元素有(Ai+Aj)(1≤i,j≤n),那么求B中所有元素的异或之和.而序列A是这样来的:A1=0,Ai=(Ai−1∗m+z) mod l. 思路:相同的元素异或结果 ...
- HDOJ 2317. Nasty Hacks 模拟水题
Nasty Hacks Time Limit: 3000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...
- ACM :漫漫上学路 -DP -水题
CSU 1772 漫漫上学路 Time Limit: 1000MS Memory Limit: 131072KB 64bit IO Format: %lld & %llu Submit ...
- ytu 1050:写一个函数,使给定的一个二维数组(3×3)转置,即行列互换(水题)
1050: 写一个函数,使给定的一个二维数组(3×3)转置,即行列互换 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 154 Solved: 112[ ...
- [poj2247] Humble Numbers (DP水题)
DP 水题 Description A number whose only prime factors are 2,3,5 or 7 is called a humble number. The se ...
- gdutcode 1195: 相信我这是水题 GDUT中有个风云人物pigofzhou,是冰点奇迹队的主代码手,
1195: 相信我这是水题 Time Limit: 1 Sec Memory Limit: 128 MBSubmit: 821 Solved: 219 Description GDUT中有个风云人 ...
- BZOJ 1303 CQOI2009 中位数图 水题
1303: [CQOI2009]中位数图 Time Limit: 1 Sec Memory Limit: 162 MBSubmit: 2340 Solved: 1464[Submit][Statu ...
- 第十一届“蓝狐网络杯”湖南省大学生计算机程序设计竞赛 B - 大还是小? 字符串水题
B - 大还是小? Time Limit:5000MS Memory Limit:65535KB 64bit IO Format: Description 输入两个实数,判断第一个数大 ...
- ACM水题
ACM小白...非常费劲儿的学习中,我觉得目前我能做出来的都可以划分在水题的范围中...不断做,不断总结,随时更新 POJ: 1004 Financial Management 求平均值 杭电OJ: ...
随机推荐
- uva 688 - Mobile Phone Coverage
经典问题,矩形面积并. 解法:一.矩形分割,每个矩形的两个横坐标和两个纵坐标排序,这样得到2n*2n个区间,对这些区间依次判断是否包含在n个矩形中间即可. 二.扫描线.具体还没实现过. 详见 ...
- jquery的鼠标移入移出事件hover、mouseenter、mouseleave、mouseover、mouseout
hover:鼠标进入元素的子元素时不会触发‘鼠标移开’的事件: mouseenter.mouseleave:效果与hover相同: mouseover: 鼠标进入元素和进入它的子元素时都会触发‘mou ...
- 作业:汽车查询--弹窗显示详情,批量删除 php做法(0521)
作业:显示以下界面: 作业要求: 1.查看详细信息,以弹窗的形式显示,使用ajax2.批量删除 一.主页面: <!DOCTYPE html PUBLIC "-//W3C//DTD XH ...
- CI框架中遇见的一些错误和解决方法 笔记
ps:根据经验不断修改和更新,欢迎指出错误~ 1. An uncaught Exception was encountered Type: Exception Message: Session: Co ...
- pyqt5:标签显示文本框内容
文本框(lineEdit)输入文本,标签(label)就会显示文本框的内容. 原理如下: 输入文本时,lineEdit控件发射信号textChanged(),label收到后触发setText()槽. ...
- Activiti 使用自己的身份认证服务
Activiti 中内置了用户和组管理的服务,由identityService 提供调用接口,默认在spring配置中如下: <bean id="identityService&quo ...
- $rootScope
参考地址 https://docs.angularjs.org/api/ng/type/$rootScope.Scope angular 的scope一般上都是有继承关系的,也就是说可以通过原型访问到 ...
- 如何看懂XDEBUG+WEBGRIND?(转)
看到一个很有用的东东,收藏.. http://blog.csdn.net/yukon12345/article/details/11408617 ~~~~~~~~~~ 使用: ...
- haskell学习笔记_函数
一开始学习函数式编程语言就被告知函数式编程语言是一种“定义式”的语言,而不是一种命令式的语言,在学习haskell的函数语法时,此感觉更加强烈,haskell的函数定义倾向于一种类似C++里面的swi ...
- 防止DC电源反接的方法——SS14的用法
出处:http://blog.ednchina.com/tengjingshu 电源是PCB板的重要部分,每个芯片都需要电源供给.芯片其实是挺脆弱的,只要正负接反得话,大多数就会挂掉,相信很多人都有惨 ...