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

建议使用的浏览器:

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

6919:Matrix

题目描述
Bob is playing a matrix game. He needs to deal with a matrix of $n$ rows and $m$ columns, satisfying the properties below:

$\qquad \cdot$ Both rows and columns are numbered from $1$

$\qquad \cdot$ All the elements in the matrix have only two values: $0$ and $1$

$\qquad \cdot$ All the elements equals $0$ initally

To play the game, Bob can apply $\operatorname{flip} (i,j)$ operations to the matrix. This operation can flip all elements whose row number is a multiple of $i$ \textbf{and} column number is a multiple of $j$ (flipping an element means change its value from $v$ to $1-v$). Bob is very bold when playing games. He always performs $\operatorname{flip}$ operations on all the positive integer pairs $(i,j)$.

After finishing all the operations, Bob wants to know how many elements which equals $1$ there are in the matrix.
输入解释
The first line is a single number $T$, indicating the number of test cases.

In the following $T$ lines, the $i$-th line contains two integers $n, m$, representing the number of rows and columns of the $i$-th matrix, respectively.

It is guaranteed that $1 \le T \le 10$ and $1 \le n, m \le 10^{18}$.
输出解释
$T$ lines, the $i$-th line a single integer - the answer of the $i$-th matrix.
输入样例
2
1 1
2 3
输出样例
1
1
来自杭电HDUOJ的附加信息
Recommend liuyiding

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

源链接: HDU-6919

最后修改于 2021-06-22T18:18:53+00:00 由爬虫自动更新

共提交 0

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