传送门:http://acm.hdu.edu.cn/showproblem.php?pid=5995
模拟
#include<stdio.h>
#include<cstring>
#define N 1000005
const int _K=50268147,_B=6082187,_P=100000007;
int _X;
inline int get_rand(int _l,int _r){
_X=((long long)_K*_X+_B)%_P;
return _X%(_r-_l+1)+_l;
}
bool fx[N],fy[N];
inline void solve()
{
memset(fx,0,sizeof(fx));
memset(fy,0,sizeof(fy));
int n,m,k,seed,ansx=0,ansy=0;
scanf("%d%d%d%d",&n,&m,&k,&seed);
_X=seed;
for (int i=1;i<=k;++i)
fx[get_rand(1,n)]=1,
fy[get_rand(1,m)]=1;
for (int i=1;i<=n;i++) if (!fx[i]) ansx++;
for (int i=1;i<=m;i++) if (!fy[i]) ansy++;
printf("%d %d\n",ansx,ansy);
}
int main()
{
int T;scanf("%d",&T);
while (T--) solve();
}