#P3583. [POI 2015 R1] 平方和 Squares

[POI 2015 R1] 平方和 Squares

Description

Consider expressing a positive integer nn as a sum of several distinct squares. For example, 30=12+22+52=12+22+32+4230 = 1^2 + 2^2 + 5^2 = 1^2 + 2^2 + 3^2 + 4^2, while 88 has no such decomposition.

Let k(n)k(n) denote the minimal possible value of the largest base among all such decompositions of nn. If no such decomposition exists, set k(n)=k(n) = \infty. For example: k(1)=1k(1) = 1, k(8)=k(8) = \infty, k(378)=12k(378) = 12, k(380)=10k(380) = 10.

A number xx is called "overweight" if and only if there exists y>xy > x such that k(y)<k(x)k(y) < k(x). From the examples above, 378378 is an "overweight" number.

Given nn, you need to:

  1. Compute k(n)k(n).
  2. Count how many "overweight" numbers are in the range from 11 to nn.

Input Format

The input contains a single line with a positive integer nn.

Output Format

Output one line containing two integers, which are the answers to the two questions above. If k(n)=k(n) = \infty, output a minus sign - instead.

30
4 15

Hint

Constraints

For 100 % of the testdata, 1n10181 \le n \le 10^{18}.

Original title: Kwadraty.

Translated by ChatGPT 5