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

建议使用的浏览器:

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

5875:Function

题目描述
The shorter, the simpler. With this problem, you should be convinced of this truth.
  
  You are given an array $A$ of $N$ postive integers, and $M$ queries in the form $(l, r)$. A function $F(l, r)\ (1\le l \le r \le N)$ is defined as:
$F(l,r)=\left\{\begin{matrix}
A_{l}&l=r; \\
F(l, r-1)\ mod A_{r}& l<r.
\end{matrix}\right.$
You job is to calculate $F(l, r)$, for each query $(l, r)$.
输入解释
There are multiple test cases.
  
  The first line of input contains a integer $T$, indicating number of test cases, and $T$ test cases follow.
  
  For each test case, the first line contains an integer $N (1\le N \le 100000)$.
  The second line contains $N$ space-separated positive integers: $A_{1},\dots, A_{N}\ (0\le A_{i} \le 10^9)$.
  The third line contains an integer $M$ denoting the number of queries.
  The following $M$ lines each contain two integers $l, r \ (1 \le l \le r \le N)$, representing a query.
输出解释
For each query$ (l, r)$, output $F(l, r)$ on one line.
输入样例
1
3
2 3 3
1
1 3
输出样例
2
来自杭电HDUOJ的附加信息
Recommend wange2014

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

源链接: HDU-5875

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

共提交 0

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