QOJ.ac

QOJ

시간 제한: 30.0 s 메모리 제한: 256 MB 총점: 100

#17335. 寻找离群值

통계

Abacus 教授刚刚制造了一台用于制作数表的新型计算引擎。它被设计为一次计算单变量多项式函数在若干个点上的值。例如,对于多项式函数 $f(x) = x^2 + 2x + 1$,一个可能的预期计算结果是 $1$($= f(0)$)、$4$($= f(1)$)、$9$($= f(2)$)、$16$($= f(3)$)和 $25$($= f(4)$)。

然而遗憾的是,该引擎似乎有故障部件,在同时计算出的值中,恰好有一个值总是错误的。对于上述相同的多项式函数,它可能会输出 $1, 4, 12, 16, 25$ 而不是 $1, 4, 9, 16, 25$。

你需要帮助教授找出故障部件。作为第一步,你应该编写一个程序,扫描引擎的计算结果并找出错误的值。

输入格式

输入由多个数据集组成,每个数据集代表一个计算结果,格式如下:

d
v0
v1
:
vd+2

这里,第一行中的 $d$ 是一个正整数,表示多项式的次数,即变量的最高指数。例如,$4x^5 + 3x + 0.5$ 的次数是 $5$,$2.4x + 3.8$ 的次数是 $1$。$d$ 最大为 $5$。

接下来的 $d + 3$ 行按顺序包含 $f(0), f(1), \dots, f(d + 2)$ 的计算结果,其中 $f$ 是该多项式函数。每行包含一个开区间 $(-100.0, 100.0)$ 内的小数。

你可以假设错误的值(即 $f(0), f(1), \dots, f(d + 2)$ 中恰好有一个)的误差大于 $1.0$。由于舍入误差不可避免,其他值也可能存在误差,但它们很小且绝不会超过 $10^{-6}$。

输入结束由包含一个零的行表示。

输出格式

对于每个数据集,当 $v_i$ 错误时,在一行中输出 $i$。

样例

样例输入 1

2
1.0
4.0
12.0
16.0
25.0
1
-30.5893962764
5.76397083962
39.3853798058
74.3727663177
4
42.4715310246
79.5420238202
28.0282396675
-30.3627807522
-49.8363481393
-25.5101480106
7.58575761381
5
-21.9161699038
-48.469304271
-24.3188578417
-2.35085940324
-9.70239202086
-47.2709510623
-93.5066246072
-82.5073836498
0

样例输出 1

2
1
1
6

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.