QOJ.ac

QOJ

حد الوقت: 0.1 s حد الذاكرة: 64 MB مجموع النقاط: 100

#12390. 正方形

الإحصائيات

我们考虑将正整数分解为若干个互不相同的正整数的平方之和,以下简称“分解”。例如,数字 $30$ 有两种分解方式:$1^2 + 2^2 + 5^2 = 30$ 和 $1^2 + 2^2 + 3^2 + 4^2 = 30$,而数字 $8$ 则没有任何分解方式。

具体来说,我们感兴趣的是给定数字 $n$ 的分解中,最大的平方数底数最小能是多少。换句话说,我们想要确定值 $k(n)$,它定义为 $n$ 的所有分解中,分解项中最大整数(不是它的平方!)的最小值。如果 $n$ 无法分解,我们假设 $k(n) = \infty$。例如,$k(1) = 1$,$k(8) = \infty$,$k(30) = 4$,$k(378) = 12$,$k(380) = 10$。

如果存在一个整数 $y > x$ 使得 $k(y) < k(x)$,我们称整数 $x$ 为“过度增长的”(overgrown)。根据前面的例子可知,$378$ 是过度增长的。

对于给定的整数 $n$,你需要确定 $k(n)$ 以及不超过 $n$ 的过度增长的整数的个数。

输入格式

标准输入的唯一一行包含一个整数 $n$ ($1 \le n \le 10^{18}$)。测试数据中,有 $45\%$ 的分数满足 $n \le 50\,000\,000$,其中 $30\%$ 的分数满足 $n \le 1\,000\,000$,更小的一部分满足 $n \le 1000$。

输出格式

程序应向标准输出打印两个整数,中间用空格隔开:第一个是 $k(n)$,第二个是范围 $[1, n]$ 内过度增长的整数个数。如果 $k(n) = \infty$,则第一个数字应打印为 -(短横线或减号)。

样例

输入 1

30

输出 1

4 15

输入 2

8

输出 2

- 5

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.