From 83924694745d4f25affa56844bd417ec7e48e43d Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Wed, 16 Nov 2022 10:03:40 +0800 Subject: [PATCH] =?UTF-8?q?#2993.=20=E3=80=8CAHOI2018=20=E5=88=9D=E4=B8=AD?= =?UTF-8?q?=E7=BB=84=E3=80=8D=E6=A0=B9=E5=BC=8F=E5=8C=96=E7=AE=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://loj.ac/s/1633416 --- LibreOJ/2993/2993.cpp | 68 ++++++++++++++++++++++++++++++++++++ LibreOJ/2993/data/cube1.ans | 3 ++ LibreOJ/2993/data/cube1.in | 3 ++ LibreOJ/2993/data/cube10.ans | 3 ++ LibreOJ/2993/data/cube10.in | 3 ++ LibreOJ/2993/data/cube2.ans | 3 ++ LibreOJ/2993/data/cube2.in | 3 ++ LibreOJ/2993/data/cube3.ans | 3 ++ LibreOJ/2993/data/cube3.in | 3 ++ LibreOJ/2993/data/cube4.ans | 3 ++ LibreOJ/2993/data/cube4.in | 3 ++ LibreOJ/2993/data/cube5.ans | 3 ++ LibreOJ/2993/data/cube5.in | 3 ++ LibreOJ/2993/data/cube6.ans | 3 ++ LibreOJ/2993/data/cube6.in | 3 ++ LibreOJ/2993/data/cube7.ans | 3 ++ LibreOJ/2993/data/cube7.in | 3 ++ LibreOJ/2993/data/cube8.ans | 3 ++ LibreOJ/2993/data/cube8.in | 3 ++ LibreOJ/2993/data/cube9.ans | 3 ++ LibreOJ/2993/data/cube9.in | 3 ++ 21 files changed, 128 insertions(+) create mode 100644 LibreOJ/2993/2993.cpp create mode 100644 LibreOJ/2993/data/cube1.ans create mode 100644 LibreOJ/2993/data/cube1.in create mode 100644 LibreOJ/2993/data/cube10.ans create mode 100644 LibreOJ/2993/data/cube10.in create mode 100644 LibreOJ/2993/data/cube2.ans create mode 100644 LibreOJ/2993/data/cube2.in create mode 100644 LibreOJ/2993/data/cube3.ans create mode 100644 LibreOJ/2993/data/cube3.in create mode 100644 LibreOJ/2993/data/cube4.ans create mode 100644 LibreOJ/2993/data/cube4.in create mode 100644 LibreOJ/2993/data/cube5.ans create mode 100644 LibreOJ/2993/data/cube5.in create mode 100644 LibreOJ/2993/data/cube6.ans create mode 100644 LibreOJ/2993/data/cube6.in create mode 100644 LibreOJ/2993/data/cube7.ans create mode 100644 LibreOJ/2993/data/cube7.in create mode 100644 LibreOJ/2993/data/cube8.ans create mode 100644 LibreOJ/2993/data/cube8.in create mode 100644 LibreOJ/2993/data/cube9.ans create mode 100644 LibreOJ/2993/data/cube9.in diff --git a/LibreOJ/2993/2993.cpp b/LibreOJ/2993/2993.cpp new file mode 100644 index 00000000..4198ea60 --- /dev/null +++ b/LibreOJ/2993/2993.cpp @@ -0,0 +1,68 @@ +#include +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +const int N = 1e6 + 5; + +int t, p, primes[N]; +bool not_prime[N]; +std::unordered_map map; + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + for (int i = 2; i < N; i++) { + if (!not_prime[i]) primes[++p] = i; + + for (int j = 1; j <= p && primes[j] * i < N; j++) { + not_prime[primes[j] * i] = true; + + if (i % primes[j] == 0) break; + } + } + + for (int i = 1; i <= p; i++) { + long long x = primes[i]; + map[x * x * x] = primes[i]; + } + + cin >> t; + + while (t--) { + long long n, ans = 1; + + cin >> n; + + int m = std::sqrt(std::sqrt(n)); + + if (map.count(n)) { + cout << map[n] << endl; + + continue; + } + + for (int i = 1, x = primes[i]; i <= p && x <= m && static_cast(x) * x * x <= n; x = primes[++i]) { + long long y = static_cast(x) * x * x; + + while (n % y == 0) { + ans *= x; + n /= y; + } + + while (n % x == 0) { + n /= x; + } + } + + if (map.count(n)) ans *= map[n]; + + cout << ans << endl; + } + + return 0; +} diff --git a/LibreOJ/2993/data/cube1.ans b/LibreOJ/2993/data/cube1.ans new file mode 100644 index 00000000..d9b43198 --- /dev/null +++ b/LibreOJ/2993/data/cube1.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:198fe5d36c0f61576985cb5bf064408924347e14646097be21f843dbcb954425 +size 28 diff --git a/LibreOJ/2993/data/cube1.in b/LibreOJ/2993/data/cube1.in new file mode 100644 index 00000000..eb9b08da --- /dev/null +++ b/LibreOJ/2993/data/cube1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f7daa16f60d114bcc8b098a875fea52dc71ef11b63a2c2a5ba71a4762f6d2386 +size 73 diff --git a/LibreOJ/2993/data/cube10.ans b/LibreOJ/2993/data/cube10.ans new file mode 100644 index 00000000..d4658549 --- /dev/null +++ b/LibreOJ/2993/data/cube10.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:b101700e9742c44545aee9328d7c5a5f32183c14e03619cf39b8aeaec8e6177d +size 54784 diff --git a/LibreOJ/2993/data/cube10.in b/LibreOJ/2993/data/cube10.in new file mode 100644 index 00000000..98aea66a --- /dev/null +++ b/LibreOJ/2993/data/cube10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:c3b39149426c892e893158095f3280c2dda0fae226f2c74c7f6947fb662caec0 +size 189516 diff --git a/LibreOJ/2993/data/cube2.ans b/LibreOJ/2993/data/cube2.ans new file mode 100644 index 00000000..b6a12b3d --- /dev/null +++ b/LibreOJ/2993/data/cube2.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:09106c46421acbbc3adb34c11c435ec3835ab23df448c3bc5bd422dec1769a7d +size 29 diff --git a/LibreOJ/2993/data/cube2.in b/LibreOJ/2993/data/cube2.in new file mode 100644 index 00000000..355da410 --- /dev/null +++ b/LibreOJ/2993/data/cube2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:94056b63a8506fdc712af5c0ca16e9b836fbd8302b3eacbefc9a76c50ac6ec24 +size 73 diff --git a/LibreOJ/2993/data/cube3.ans b/LibreOJ/2993/data/cube3.ans new file mode 100644 index 00000000..d9d994d4 --- /dev/null +++ b/LibreOJ/2993/data/cube3.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:33f6c84c50143dbfeaf6a9c4e947a3895687a78b08827aae1b3ab39fb121427f +size 37 diff --git a/LibreOJ/2993/data/cube3.in b/LibreOJ/2993/data/cube3.in new file mode 100644 index 00000000..c219ae17 --- /dev/null +++ b/LibreOJ/2993/data/cube3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:1c961c88fc036baff1f811b100f93dca9a98738da41e2b644876bcc06e83cf66 +size 101 diff --git a/LibreOJ/2993/data/cube4.ans b/LibreOJ/2993/data/cube4.ans new file mode 100644 index 00000000..c870bbe8 --- /dev/null +++ b/LibreOJ/2993/data/cube4.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:52d9f7cde09e10674d3ef8c1e91f51a7117118059e40e2331e060d5ff8a4f8e5 +size 38 diff --git a/LibreOJ/2993/data/cube4.in b/LibreOJ/2993/data/cube4.in new file mode 100644 index 00000000..6fe3cb36 --- /dev/null +++ b/LibreOJ/2993/data/cube4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:680968250d0526b5156fbd5a1a515901bcb5daa9fff87aa24a6ba44b47cf5ae0 +size 101 diff --git a/LibreOJ/2993/data/cube5.ans b/LibreOJ/2993/data/cube5.ans new file mode 100644 index 00000000..528c415a --- /dev/null +++ b/LibreOJ/2993/data/cube5.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:726a84dbe8e9b5de98431f5a8ede0ade28bcb20d36a7c6446d1498f0e3dc0e17 +size 700 diff --git a/LibreOJ/2993/data/cube5.in b/LibreOJ/2993/data/cube5.in new file mode 100644 index 00000000..09ea6a7b --- /dev/null +++ b/LibreOJ/2993/data/cube5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:696e020e03cfd707927d1765079ebddcce2ead69bb0592213c8d47a4eeebb723 +size 1851 diff --git a/LibreOJ/2993/data/cube6.ans b/LibreOJ/2993/data/cube6.ans new file mode 100644 index 00000000..c5f7c70c --- /dev/null +++ b/LibreOJ/2993/data/cube6.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:da710c6e85cf39ba5073cac3b2c52c0e43cc14bc3834176bdbd212203c01970b +size 700 diff --git a/LibreOJ/2993/data/cube6.in b/LibreOJ/2993/data/cube6.in new file mode 100644 index 00000000..863a558b --- /dev/null +++ b/LibreOJ/2993/data/cube6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8bd80fa60a5ababbd2859039b21872995f3b41ff7672db07d1b8408433398fd8 +size 1848 diff --git a/LibreOJ/2993/data/cube7.ans b/LibreOJ/2993/data/cube7.ans new file mode 100644 index 00000000..2d6efe1e --- /dev/null +++ b/LibreOJ/2993/data/cube7.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f56878b9e11eaffee84927263e77fb5882ab4e52508a0357c7f27c53cc5ff03c +size 2381 diff --git a/LibreOJ/2993/data/cube7.in b/LibreOJ/2993/data/cube7.in new file mode 100644 index 00000000..4bfcdfff --- /dev/null +++ b/LibreOJ/2993/data/cube7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:76ce051e0a66ec59031942413ba9475f6e6488843e8ca3abeb4251a90b8ecb01 +size 9498 diff --git a/LibreOJ/2993/data/cube8.ans b/LibreOJ/2993/data/cube8.ans new file mode 100644 index 00000000..da73d51d --- /dev/null +++ b/LibreOJ/2993/data/cube8.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f8fab7096b4605b9fa856cabd8ebfb53daeca45397337ac22f76d753ed493ced +size 2378 diff --git a/LibreOJ/2993/data/cube8.in b/LibreOJ/2993/data/cube8.in new file mode 100644 index 00000000..bf6bd73a --- /dev/null +++ b/LibreOJ/2993/data/cube8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e2d0e0545beab83ddf312398ce436296e32c59c890c7ec370071ce9ec71ba4fc +size 9498 diff --git a/LibreOJ/2993/data/cube9.ans b/LibreOJ/2993/data/cube9.ans new file mode 100644 index 00000000..cf40ed74 --- /dev/null +++ b/LibreOJ/2993/data/cube9.ans @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:ea0c35ecc10d992e36e4ba0b5aa5f0c0b11c75d4c8353bc2f18779aa0cfc7b14 +size 54727 diff --git a/LibreOJ/2993/data/cube9.in b/LibreOJ/2993/data/cube9.in new file mode 100644 index 00000000..d278d2a0 --- /dev/null +++ b/LibreOJ/2993/data/cube9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:81251eaf3fe0ce682f74f3e69c7c60bf6644570c2782224351d08b0986f6faeb +size 189516