#P4446. [AHOI2018初中组] 根式化简

    ID: 3339 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>数学2018安徽枚举,暴力素数判断,质数,筛法概率论,统计

[AHOI2018初中组] 根式化简

Description

While learning about cube roots, Keke encountered the following problem:

Simplify the following radicals to their simplest forms:

(1) 1253\sqrt[3]{125} (2) 813\sqrt[3]{81} (3) 523\sqrt[3]{52}

This was too easy for Keke, and he quickly got the answers:

(1) 55 (2) 3333\sqrt[3]{3} (3) 523\sqrt[3]{52}

Keke knows that any radical of the form x3\sqrt[3]{x} can be simplified to the simplest form ab3a\sqrt[3]{b}. He found this interesting and created many similar problems, but soon got overwhelmed, so he asked you for help:

Given nn radicals of the form x3\sqrt[3]{x}, simplify each to the simplest form ab3a\sqrt[3]{b}. For convenience, you only need to output aa.

If you have not learned this topic, you can think of it as: given nn positive integers xx, for each xx, find integers a,ba, b such that a3×b=xa^3 \times b = x, and output the largest integer aa.

Input Format

The input has two lines:

  • The first line contains an integer nn, the number of radicals of the form x3\sqrt[3]{x}.
  • The second line contains nn positive integers, giving each xx in order.

Output Format

Output nn lines, each with a positive integer. The ii-th line contains the answer for the ii-th xx in the input.

3
125 81 52
5
3
1

Hint

For 100%100\% of the testdata: 1n100001 \le n \le 10000, 1x10181 \le x \le 10^{18}.

There are 10 test points, numbered 1101 \sim 10, with the following additional guarantees:

1 ~ 2: n10n \le 10, x106x \le 10^6.
3 ~ 4: n10n \le 10, x109x \le 10^9.
5 ~ 6: n100n \le 100, x1018x \le 10^{18} and xx is a perfect cube.
7 ~ 8: n500n \le 500, x1018x \le 10^{18}.
9 ~ 10: n10000n \le 10000, x1018x \le 10^{18}.

Translated by ChatGPT 5