QOJ.ac

QOJ

Time Limit: 1.0 s Memory Limit: 256 MB Total points: 100 Hackable ✓

#15845. An Easy Calculus Problem

Statistics

国际微积分问题委员会(International Calculus Problem Committee)慷慨地为今天的比赛提供了一道题目。让我们一起向他们表示感谢!

设 $a, b, c$ 和 $d$ 为实数常数。定义分段函数 $f$ 在所有实数 $x$ 上的表达式如下:

$$f(x) = \begin{cases} -(x+4)^2 + 8, & \text{if } x \in (-\infty, -3], \\ ax+b, & \text{if } x \in (-3, 2], \\ x^3 + cx + d, & \text{if } x \in (2, +\infty). \end{cases}$$

此外,已知 $f$ 在处处可导。我们可以证明,确实存在唯一的一组 $a, b, c$ 和 $d$ 的值使得 $f$ 在处处可导,因此该条件足以唯一确定 $f$。

任务如下:给定一个整数 $x$ 作为输入,输出 $f(x)$ 的值。可以证明,如果 $x$ 是整数,那么 $f(x)$ 的值也一定是一个整数。

等等,首席裁判说这个问题不太合适,因为这是一场编程竞赛,而不是微积分课。

因此,为了公平起见,我们给你一个提示:$f$ 在处处可导当且仅当 $a = -2, b = 1, c = -14$ 且 $d = 17$。这些就是你应该用于 $f$ 的值。看,我甚至会向你展示该函数的图像,以证明它在处处可导。

当我们取 $a = -2, b = 1, c = -14$ 且 $d = 17$ 时,$y = f(x)$ 的图像。我们可以看到该函数在处处可导。此图像由 Desmos 生成。

输入格式

输入仅包含一行,即整数 $x$。

数据范围

  • $-10 \le x \le 10$

注意:保证满足上述数据范围。你无需检查它们;可以假设它们始终成立。

输出格式

输出一个整数,即 $f$ 在给定 $x$ 处的值。

我们提醒你,不要输出小数点或小数点后的任何位数。

样例

输入 1

-7

输出 1

-1

输入 2

0

输出 2

1

输入 3

3

输出 3

2

说明

在第三个样例输入中,我们希望计算 $f(3)$。根据分段函数的定义,因为 $3 \in (2, +\infty)$,我们将在 $x = 3$ 时计算 $x^3 + cx + d$ 的值。使用提示中给出的 $c$ 和 $d$ 的值,我们得到:

$$3^3 + (-14)3 + 17 = 27 - 42 + 17 = 2.$$

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.