标签:
转载请注明出处: http://www.cnblogs.com/fraud/ ——by fraud
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 488 Accepted Submission(s): 342
两个相同的数异或之后等于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 }
标签:
原文地址:http://www.cnblogs.com/fraud/p/4705805.html