当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6424:Rikka with Time Complexity

题目描述
Calculating and comparing time complexity for algorithms are the most important necessary skills for CS students.

This semester, Rikka applies for the assistant of course "Algorithm Analysis". Now Rikka needs to set problems for the final examination, and she is going to set some tasks about time complexity.

Let $f_a(n) = \log \dots \log n$ (there are exactly $a$ $\log$ in this function, and $\log$ uses base $2$). And then, for an integer array $A$, Rikka defines $g_A(n)$ in the following way ($B$ is the suffix of $A$ with length $|A| - 1$):
\begin{align*}
g_A(n) = \begin{cases}
f_{A_1}(n) & |A| = 1 \\
f_{A_1}(n)^{g_B(n)} & |A| > 1
\end{cases}
\end{align*}

For example, $g_{[1,2]}(n) = (\log n) ^{\log \log n}$ and $g_{[3,1,1]}(n) = (\log \log \log n) ^{(\log n) ^{\log n}}$.

Now, given integer arrays $A$ and $B$, Rikka wants you to compare $g_A(n)$ with $g_B(n)$. i.e., let $k$ be $\lim_{n \rightarrow +\infty}\frac{g_A(n)}{g_B(n)}$. If $k = 0$, output $-1$; if $k = +\infty $, output $1$; otherwise output $0$.
输入解释
The first line contains a single number $t(1 \leq t \leq 10^5)$, the number of testcases.

For each testcase, the first line contains two integers $a,b(1 \leq a,b \leq 3)$, the length of $A$ and $B$.

The second line contains $a$ integers $A_i$ and the third line contains $b$ integers $B_i(1 \leq A_i,B_i \leq 10^9)$, which describe $A$ and $B$.
输出解释
For each testcase, output a single line with a single integer, the answer.
输入样例
3
1 1
1
2
2 2
1 2
2 1
1 3
1
1000000000 3 3
输出样例
1
-1
-1
来自杭电HDUOJ的附加信息
Recommend chendu

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6424

最后修改于 2020-10-25T23:31:13+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 524288/524288K(Java/Others)