QOJ.ac

QOJ

Limite de temps : 4 s Limite de mémoire : 1024 MB Points totaux : 100

#3003. 生活成本

Statistiques

一位报纸专栏作家最近写了一篇专栏文章,将迪士尼的涨价幅度与经济中的其他事物进行了比较;例如,如果汽油价格自 1990 年以来的上涨速度与迪士尼门票价格的上涨速度相同,那么每加仑汽油的价格将达到 $\$6.66$。

考虑若干商品在连续多年内的价格。从第 $x$ 年到下一年 $(x+1)$ 存在一个通货膨胀率($\text{inflation}(x)>0$)。此外,每种商品 $A$ 都有一个对于该商品固定的修正系数($\text{modifier}(A)>0$)。因此,对于第 $x+1$ 年的商品 $A$:

$$ \text{price}(A, x+1)= \text{price}(A, x) \bullet \text{inflation}(x) \bullet \text{modifier}(A) $$

遗憾的是,修正系数是未知的,且部分价格和通货膨胀率也是未知的。

给定部分通货膨胀率、若干商品在连续多年内的价格,以及一些关于特定商品在特定年份价格的查询,请回答这些查询。

输入格式

每个测试用例以一行三个空格分隔的整数开始:$y$ ($1 \leq y \leq 10$)、$c$ ($1\leq c \leq 100$) 和 $q$ ($1 \leq q \leq y\bullet c$),其中 $y$ 是连续年份的数量,$c$ 是商品的数量,$q$ 是需要回答的查询数量。

接下来的 $y-1$ 行,每行包含一个实数 $r$ ($1.0 \leq r \leq 1.5$ 或 $r = -1.0$),表示通货膨胀率。值为 $-1.0$ 表示通货膨胀率未知。第一个通货膨胀率是从第 $1$ 年到第 $2$ 年的变化,第二个是从第 $2$ 年到第 $3$ 年的变化,依此类推。已知的通货膨胀率符合指定的限制;未知但可唯一确定的通货膨胀率可能不符合这些限制,但保证严格大于零。

接下来的 $y$ 行描述每一年的价格。每行包含 $c$ 个空格分隔的实数 $p$ ($1.0 < p < 1,000,000.0$ 或 $p=−1.0$),表示该商品在当年的价格。值为 $-1.0$ 表示价格未知。

接下来的 $q$ 行,每行包含两个空格分隔的整数 $a$ ($1 \leq a \leq c$) 和 $b$ ($1 \leq b \leq y$),表示查询商品 $a$ 在第 $b$ 年的价格。所有查询均不相同。

所有可以唯一确定的价格都将严格大于零且严格小于 $1,000,000.0$。输入中的价格和通货膨胀率数值可能不精确,但精确到小数点后 $10$ 位。所有实数值的小数点后不超过 $10$ 位。

输出格式

输出 $q$ 行。每行应包含一个实数,即给定商品在给定年份的价格;如果无法确定,则输出 $-1.0$。请按照输入中查询出现的顺序回答。如果你的答案与标准答案的绝对误差或相对误差在 $10^{-4}$ 以内,则视为正确。

样例

样例输入 1

4 2 2
1.3333333333
1.2500000000
-1
3.00 -1
4.00 8.00
5.00 10.00
-1 11.00
2 1
1 4

样例输出 1

6.0000000000
5.5000000000

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.