2019-07-06から1日間の記事一覧

Codeforces Round #572 (Div. 1) B. Count Pairs

https://codeforces.com/contest/1188/problem/B\begin{align} & (x+y)(x^2+y^2)=k \\ \iff & x^3 + x^2 y + x y^2 + y^3 = k \\ \iff & \frac{x^4-y^4}{x-y}=k \\ \iff & x^4 - kx=y^4 - ky \end{align} My first approach is to solving cubic equation. I…

Codeforces Round #572 (Div. 1) C. Array Beauty

https://codeforces.com/contest/1188/problem/CSuppose that the array is already sorted. Let f(x) be the number of subarrays such that any difference between adjacent elements is greater than or equal to x. We then have the answer as f(1)+f(…