#P1679. 神奇的四次方数

    ID: 653 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 3 上传者: 标签>模拟动态规划,dp搜索数学背包

神奇的四次方数

Description

Decompose an integer mm into a sum of nn fourth powers, with nn being as small as possible. For example, when m=706m=706, since 706=54+34706=5^4+3^4, we have n=2n=2. It can be proven that in this case nn is minimal.

Input Format

One line, an integer mm.

Output Format

One line, an integer nn.

706
2

Hint

Constraints

  • For 30%30\% of the testdata, m5000m \le 5000.
  • For 100%100\% of the testdata, m100,000m \le 100{,}000.

Translated by ChatGPT 5