#include <iostream> //1002 #include<set> #include<stdio.h> using namespace std; const int maxn=500000+10; typedef long long ll; int a[maxn]; int main() { int n,z,l; ll m; int t; scanf("%d",&t); while(t--) { scanf("%d%lld%d%d",&n,&m,&z,&l); a[1]=0; for(int i=2;i<=n;i++) a[i]=(a[i-1]*m+z)%l; // for(int i=1;i<=n;i++) // cout<<a[i]<<" "; ll ans=0; for(int i=1;i<=n;i++) ans^=2*a[i]; printf("%lld\n",ans); } return 0; }
#include <iostream>//1005 #include <stdio.h> using namespace std; int main() { int T,a,b; int s[90]={0,1312,2372,520,932,800,1086,1402,1313,1681,2080,495,737,577,786,1011,999,1251,1520}; s[35]=1139; s[36]=1350; s[53]=1008; s[54]=1170; s[85]=920; s[86]=1037; while(scanf("%d%d",&a,&b)!=EOF) { printf(s[a]>s[b]?"FIRST BIGGER\n":"SECOND BIGGER\n"); } return 0; }
#include <iostream> //1007 #include<set> #include<stdio.h> using namespace std; int main() { int n; while(scanf("%d",&n)!=EOF) { multiset<int>que; multiset<int>::iterator it; for(int i=1;i<=n;i++) { int a; scanf("%d",&a); if(a==1) { int b; scanf("%d",&b); que.insert(b); } if(a==2) { //int b; // scanf("%d",&b); if(!que.empty()) it=que.begin(),que.erase(*it); } if(a==3) { if(que.empty()) printf("0\n"); else { it=que.end(); it--; printf("%d\n",(*it)); // cout<<*it<<endl; } } } } return 0; }