QOJ.ac

QOJ

Límite de tiempo: 2.0 s Límite de memoria: 1024 MB Puntuación total: 100

#8170. $N^a (\log N)^b$

Estadísticas

给定一个正整数 $N$ 的函数 $F(N)$,该函数以字符串 $F$ 的形式给出,遵循以下 BNF 范式:

$\langle \text{expr} \rangle ::= \langle \text{term} \rangle \mid \langle \text{expr} \rangle \text{ '+' } \langle \text{term} \rangle$ $\langle \text{term} \rangle ::= \langle \text{factor} \rangle \mid \langle \text{term} \rangle \text{ '*' } \langle \text{factor} \rangle$ $\langle \text{factor} \rangle ::= \text{ 'N' } \mid \text{ 'N^' } \langle \text{number} \rangle \mid \text{ 'log(' } \langle \text{expr} \rangle \text{ ')' } \mid \text{ 'log(' } \langle \text{expr} \rangle \text{ ')^' } \langle \text{number} \rangle \mid \text{ '(' } \langle \text{expr} \rangle \text{ ')' }$ $\langle \text{number} \rangle ::= \langle \text{nonzero\_digit} \rangle \mid \langle \text{nonzero\_digit} \rangle \langle \text{digit\_string} \rangle$ $\langle \text{digit\_string} \rangle ::= \langle \text{digit} \rangle \mid \langle \text{digit} \rangle \langle \text{digit\_string} \rangle$ $\langle \text{nonzero\_digit} \rangle ::= \text{ '1' } \mid \text{ '2' } \mid \text{ '3' } \mid \text{ '4' } \mid \text{ '5' } \mid \text{ '6' } \mid \text{ '7' } \mid \text{ '8' } \mid \text{ '9' }$ $\langle \text{digit} \rangle ::= \text{ '0' } \mid \langle \text{nonzero\_digit} \rangle$

符号含义如下:

  • $N$: $N$
  • $+$: 加法 $+$
  • $*$: 乘法 $\times$
  • $\text{log}$: 自然对数 $\log$
  • $(, )$: 括号,优先级高于加法 $+$ 或乘法 $*$
  • $\text{^}$: 幂运算,优先级高于加法 $+$ 或乘法 $*$

$\langle \text{number} \rangle$ 表示一个十进制整数,保证在 $1$ 到 $10^9$ 之间。此外,‘log(’ $\langle \text{expr} \rangle$ ‘)^’ $\langle \text{number} \rangle$ 表示 $(\log(\text{expr}))^{\text{number}}$。

虽然 $F(N)$ 可能并未对所有正整数 $N$ 定义,但对于任何输入,都存在一个正整数 $N_0$,使得 $F(N)$ 对所有 $N \ge N_0$ 的正整数都有定义。

因此,定义集合 $S$ 为所有满足以下极限收敛于有限值(包括 $0$)的非负整数对 $(a, b)$ 的集合: $$\lim_{N \to \infty} \frac{F(N)}{N^a (\log N)^b}$$ 输出 $S$ 中字典序最小的对 $(a, b)$。这里,非负整数对 $(a, b)$ 在 $S$ 中是字典序最小的,当且仅当它属于 $S$,且对于 $S$ 中的任何其他对 $(a', b')$,满足: * $a < a'$ * 或者 $a = a'$ 且 $b \le b'$

已证明 $S$ 非空,且存在字典序最小的对。

输入格式

输入通过标准输入给出,格式如下:

$F$

  • 函数 $F(N)$ 以字符串 $F$ 的形式给出,遵循题目描述中定义的 $\langle \text{expr} \rangle$ 符号。
  • $1 \le |F| \le 10^5$

输出格式

输出 $S$ 中字典序最小的对 $(a, b)$,中间用空格隔开。

样例

样例 1

N*log(N^2)*log(N)+N+log(N^1+N)^2*N
1 2

样例 2

N*log(log(N))
1 1

样例 3

(((N))*N^234567890+N^2)
234567891 0

说明

在第一个样例中,$F(N) = N \times \log(N^2) \times \log(N) + N + (\log(N^1 + N))^2 \times N$。 对于此情况,使得上述极限收敛于有限值的非负整数对 $(a, b)$ 包括 $(1, 2), (1, 3), (2, 0)$ 等。对于这些对,极限如下: $$\lim_{N \to \infty} \frac{F(N)}{N^1 (\log N)^2} = 3$$ $$\lim_{N \to \infty} \frac{F(N)}{N^1 (\log N)^3} = 0$$ $$\lim_{N \to \infty} \frac{F(N)}{N^2 (\log N)^0} = 0$$ 注意 $0$ 被视为有限值。另一方面,例如 $(a, b) = (1, 1)$ 会导致: $$\lim_{N \to \infty} \frac{F(N)}{N^1 (\log N)^1} = \infty$$ 且不收敛于有限值。 可以证明在满足条件的所有对集合 $S$ 中,$(a, b) = (1, 2)$ 是字典序最小的。

在第二个样例中,$F(N) = N \times \log(\log(N))$。对于 $(a, b) = (1, 1)$: $$\lim_{N \to \infty} \frac{F(N)}{N^1 (\log N)^1} = 0$$ 且收敛于有限值。 可以证明在满足条件的所有对集合 $S$ 中,$(a, b) = (1, 1)$ 是字典序最小的。

在第三个样例中,$F(N) = (((N)) \times N^{234567890} + N^2)$。

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.