Logo Universal Online Judge

UOJ

时间限制:4 s 空间限制:1024 MB
统计

【题目描述】

给你两个序列 $a$, $b$,每次询问给出 $l$, $r$, $x$,求 $\sum\limits_{i=l}^r\frac{a_i}{b_i+x}$

【输入格式】

第一行两个整数 $n$, $q$ 分别表示序列长度、询问次数。第二行 $n$ 个整数表示 $a$。 第三行 $n$ 个整数表示 $b$。 接下来 $q$ 行,每行三个整数 $l$, $r$, $x$ 表示询问。

【输出格式】

输出 $q$ 行,每行一个实数表示答案。你的答案只需与标准答案相差不超过 $10^{-6}$ 即可。

【样例 1 输入】

5 5
3 4 1 2 8
10 9 2 2 9
3 5 1
3 4 6
2 2 8
4 4 1
4 4 3

【样例 1 输出】

1.800000000000
0.375000000000
0.235294117647
0.666666666667
0.400000000000

【样例 2】

见下发文件 ex_frac2.inex_frac2.out,该测试用例满足测试点 1 ∼ 2 的约束条件。

【样例 3】

见下发文件 ex_frac3.inex_frac3.out,该测试用例满足测试点 3 ∼ 4 的约束条件。

【样例 4】

见下发文件 ex_frac4.inex_frac4.out

【数据规模与约定】

全部数据均保证 $1 \leq n \leq 3 \times 10^5,1 \leq q \leq 10^6,1 \leq x \leq 10^6,1 \leq l \leq r \leq n,1 \leq a_i \leq b_i \leq 10^6$。

本题共有 $10$ 个测试点,每个测试点 $10$ 分,各个测试点详细信息如下:

测试点编号 $n \leq$ $q \leq$
$1 \sim 2$ $1000$ $1000$
$3\sim 4 $ $10^5$ $10^5$
$5 \sim 10$ $3 \times 10^5$ $10^6$

【提示】

可以使用下发文件中的 checker.cpp 以检验你的输出的正确性,使用时先将其编译为可执行文件 checker(在 Windows 系统下为编译为 checker.exe)。

  • Linux 系统使用 ./checker <input-file> <output-file> <ans-file> 测试;
  • Windows 系统使用 checker <input-file> <output-file> <ans-file> 测试。

其中 <input-file> <output-file> <ans-file>分别是输入文件、选手输出和标准答案。

sample