当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

5995:Kblack loves flag

题目描述
Kblack loves flags, so he has infinite flags in his pocket.

One day, Kblack is given an $n*m$ chessboard and he decides to plant flags on the chessboard where the position of each flag is described as a coordinate $\left(x,y \right)$, which means that the flag is planted at the $x$th line of the $y$th row.

After planting the flags, Kblack feels sorry for those lines and rows that have no flags planted on, so he would like to know that how many lines and rows there are that have no flags planted on.

Well, Kblack, unlike you, has a date tonight, so he leaves the problem to you. please resolve the problem for him.
输入解释
You should generate the input data in your programme.

We have a private variable $x$ in the generation,which equals to $seed$ initially.When you call for a random number ranged from $[l,r]$,the generation will trans $x$ into $\left(50268147x+6082187\right)\ mod\ 100000007$.And then,it will return $x\ mod\ \left(r-l+1 \right)+l$.

The first line contains a single integer $T$ refers to the number of testcases.

For each testcase,there is a single line contains 4 integers $n, m, k, seed$.

Then,you need to generate the $k$ flags' coordinates.

For $i=1\cdots k$,firstly generate a random number in the range of $\left[1,n \right]$.Then generate a random number in the range of $\left[1,m \right]$.

You can also copy the following code and run "Init" to generate the x[],y[] (only for C++ players).

<pre>
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;
}
int n,m,k,seed;
int x[1000001],y[1000001];
void Init(){
  scanf("%d%d%d%d",&n,&m,&k,&seed);
  _X=seed;
  for (int i=1;i<=k;++i)
    x[i]=get_rand(1,n),
    y[i]=get_rand(1,m);
}
</pre>

$\left(1\leq T\leq 7 \right)$,$\left(1\leq n,m\leq 1000000 \right)$,$\left(0\leq k\leq 1000000 \right)$,$\left(0\leq seed<100000007 \right)$
输出解释
For each testcase,print a single line contained two integers,which respectively represent the number of lines and rows that have no flags planted.
输入样例
2
4 2 3 233
3 4 4 2333
输出样例
2 1
1 0

提示
the flags in the first case:$\left(4,2\right)$,$\left(1,2\right)$,$\left(1,2\right)$

the flags in the second case:$\left(2,1 \right)$,$\left(2,3\right)$,$\left(3,4\right)$,$\left(3,2\right)$

来自杭电HDUOJ的附加信息
Recommend wange2014

该题目是Virtual Judge题目,来自 杭电HDUOJ

题目来源 BestCoder Round #90

源链接: HDU-5995

最后修改于 2020-10-25T23:27:22+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 65536/65536K(Java/Others)