标签:
题目地址:http://acm.hdu.edu.cn/showproblem.php?pid=5344
1 #include<stdio.h> 2 #include<cstring> 3 const int MAXN = 500010; 4 int A[MAXN]; 5 void bas( int n, int m, int z, int l){ 6 for( int i = 1;i < n; ++i){ 7 A[i] = ( (long long)A[i-1]*m + z )% l; 8 } 9 } 10 void Cal(int n){ 11 int sum = 0; 12 for( int i = 0;i < n; ++i){ 13 sum = sum ^ (A[i]*2); 14 } 15 printf("%d\n",sum); 16 } 17 int main() 18 { 19 int n, m, z, l; 20 int T; 21 scanf("%d",&T); 22 while(T--){ 23 memset(A,0,sizeof(A)); 24 scanf("%d %d %d %d",&n,&m,&z,&l); 25 bas(n,m,z,l); 26 Cal(n); 27 } 28 }
标签:
原文地址:http://www.cnblogs.com/blueprintf/p/4703562.html