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

建议使用的浏览器:

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

5084:HeHe

题目描述
$$M = \begin{pmatrix}
t_{n-1} & t_n & t_{n+1} & \cdots & t_{2*n-3} & t_{2*n-2}\\
t_{n-2} & t_{n-1} & t_n & \cdots & t_{2*n-4} & t_{2*n-3}\\
t_{n-3} & t_{n-2} & t_{n-1} & \cdots & t_{2*n-5} & t_{2*n-4}\\
\vdots & \vdots & \vdots & \ddots & \vdots & \vdots\\
t_1 & t_2 & t_3 & \cdots & t_{n-1} & t_n\\
t_0 & t_1 & t_2 & \cdots & t_{n-2} & t_{n-1}\\
\end{pmatrix}$$
You are expected to write a program to point out some elements of $M*M$.
输入解释
Multi test cases (about 100), every case occupies two lines.
The first line contains an integer n.
Then second line contain 2*n-1 integers $t_0, t_1, t_2, t_3, \ldots, t_{2*n-4}, t_{2*n-3}, t_{2*n-2}$ separated by exact one space.
The third line contains an integer m, indicates the number of query.
Next m lines will give queries
$\begin{matrix}
r_0 & c_0\\
r_1 & c_1\\
r_2 & c_2\\
\vdots & \vdots\\
r_{m-1} & c_{m-1}
\end{matrix}$
For $r_0, c_0$ the program will query the element of $M*M$ which locates in the $r_0^{th}$ row, $c_0^{th}$ column. For $r_i, c_i(0<i<m)$, assume that the answer of $i-1^{th}$ query is ANS, the program will query the element of $M*M$ which locates in $((r_i+ANS) \% n)^{th}$ row, $((c_i+ANS) \% n)^{th}$ column.
Please process to the end of file.
[Technical Specification]
$1 \leq n \leq 1000$
$0 \leq t_i \leq 100$
$0 \leq r_i, c_i \leq n-1$
$1 \leq m \leq 100000$
输出解释
For each case,output the sum of the answer of each query.
输入样例
3
1 2 3 1 2
2
0 0
1 2
4
10 5 7 2 10 5 7
3
1 2
3 0
2 1
2
1 2 3
4
0 0
0 1
1 0
1 1
输出样例
23
348
22
提示
$\quad\  \text{For the first case }M = \begin{pmatrix}
3 & 1 & 2\\ 
2 & 3 & 1\\ 
1 & 2 & 3
\end{pmatrix}$

$\text{For the second case }M = \begin{pmatrix}
2 & 10 & 5 & 7\\ 
7 & 2 & 10 & 5\\ 
5 & 7 & 2 & 10\\ 
10 & 5 & 7 & 2
\end{pmatrix}$
来自杭电HDUOJ的附加信息
Recommend heyang

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

题目来源 BestCoder Round #15

源链接: HDU-5084

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

共提交 0

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