시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 (추가 시간 없음) 512 MB 12 5 2 40.000%

문제

Write a function P7:

  • input parameter: integers a, b, c, d satisfying $1\le\max(|$a$|,|$b$|,|$c$|,|$d$|)\le10^9$
  • return value: a list of all rational roots of the equation a$x^3+$b$x^2+$c$x+$d$=0$, in any order (Each root should be included only once.)
    • Suppose that $[t_0,t_1,\cdots,t_{n-1}]$ is the exact answer and $[u_0,u_1,\cdots,u_{m-1}]$ is your output.
    • Let $r(k)=\{i\in\mathbb Z:0\le i<k\}=\{0,1,\cdots,k-1\}$ for every non-negative integer $k$.
    • Your answer will be graded correct iff there exists a bijective function $\sigma\colon r(n)\to r(m)$ such that \[\frac{|u_{\sigma(i)}-t_i|}{\max(1,|t_i|)}\le10^{-6}\qquad\text{for all }i\in r(n)\]
  • Hint: The rational root theorem states the following:
    • Consider a polynomial function $f(x)=a_nx^n+a_{n-1}x^{n-1}+\cdots+a_0$ with integer coefficients where $a_n$ and $a_0$ are nonzero.
    • If $\displaystyle f\left(\frac{p}{q}\right)=0$, where $|p|$ and $|q|$ are relatively prime positive integers, then $\displaystyle\frac{a_0}{p}$ and $\displaystyle\frac{a_n}{q}$ are integers.

출처

High School > 한국과학영재학교 > 2021 Spring CS1 Final Mock Exam 7번

  • 문제를 만든 사람: parkky

제출할 수 있는 언어

PyPy3

채점 및 기타 정보

  • 예제는 채점하지 않는다.