Skip to content

Instantly share code, notes, and snippets.

@ochaochaocha3
Last active July 3, 2022 04:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ochaochaocha3/bc86044fe70aa0466c349d63f6edb2ef to your computer and use it in GitHub Desktop.
Save ochaochaocha3/bc86044fe70aa0466c349d63f6edb2ef to your computer and use it in GitHub Desktop.
Twitterの2次関数の問題

Twitterの2次関数の問題

https://twitter.com/ikeikey/status/1538698742718681089

$$ f(x) = ax^2 + bx + c = a \left(x + \frac{b}{2a} \right)^2 + c - \frac{b^2}{4a} $$

$$ a, b, c \in \{1, 2, 3, 4, 5, 6, 7, 8, 9\} $$

$f(x)$ が最小となる $x$ の形から、最小値は $f(-\frac{b}{2a}) = c - \frac{b^2}{4a}$。$c$ は整数だから、$\frac{b^2}{4a}$ も整数。$b^2$ は4の倍数だから $b$ は偶数。

また、$-1 < -\frac{b}{2a}$ より $b &lt; 2a$

これらの条件を満たす $a$、$b$ の組合せは

  • $a = 4$、$b = 4$ $\Rightarrow$ $\frac{b^2}{4a} = \frac{16}{16} = 1$、$\frac{b}{2a} = \frac{4}{8} = \frac{1}{2}$
  • $a = 9$、$b = 6$ $\Rightarrow$ $\frac{b^2}{4a} = \frac{36}{36} = 1$、$\frac{b}{2a} = \frac{6}{18} = \frac{1}{3}$
  • $a = 8$、$b = 8$ $\Rightarrow$ $\frac{b^2}{4a} = \frac{64}{32} = 2$、$\frac{b}{2a} = \frac{8}{16} = \frac{1}{2}$

最大値 $f(1) = a + b + c$

  • $a = 4$、$b = 4$ $\Rightarrow$ $f(1) = 8 + c$
  • $a = 9$、$b = 6$ $\Rightarrow$ $f(1) = 15 + c &gt; 9$ なので不適。
  • $a = 8$、$b = 8$ $\Rightarrow$ $f(1) = 16 + c &gt; 9$ なので不適。

$a = 4$、$b = 4$ として $f(1) = 8 + c \le 9 \Rightarrow c \le 1$。$c > 0$ だから $c = 1$

よって $a = 4$、$b = 4$、$c = 1$。最小値 $f(-\frac{1}{2}) = 0$。最大値 $f(1) = 9$

4 4 1 1 2 0 1 9
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment