From c26bcdc9f79594387bc0e9a23c7918753239159c Mon Sep 17 00:00:00 2001 From: Baoshuo Date: Thu, 22 Dec 2022 21:53:02 +0800 Subject: [PATCH] =?UTF-8?q?3629.=20[JLOI2014]=20=E8=81=AA=E6=98=8E?= =?UTF-8?q?=E7=9A=84=E7=87=95=E5=A7=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit https://hydro.ac/d/bzoj/record/63a4610db053be17396a0964 --- BZOJ/3629/3629.cpp | 79 +++++++++++++++++++++++++++++++++++++++++++ BZOJ/3629/data/1.in | 3 ++ BZOJ/3629/data/1.out | 3 ++ BZOJ/3629/data/10.in | 3 ++ BZOJ/3629/data/10.out | 3 ++ BZOJ/3629/data/11.in | 3 ++ BZOJ/3629/data/11.out | 3 ++ BZOJ/3629/data/2.in | 3 ++ BZOJ/3629/data/2.out | 3 ++ BZOJ/3629/data/3.in | 3 ++ BZOJ/3629/data/3.out | 3 ++ BZOJ/3629/data/4.in | 3 ++ BZOJ/3629/data/4.out | 3 ++ BZOJ/3629/data/5.in | 3 ++ BZOJ/3629/data/5.out | 3 ++ BZOJ/3629/data/6.in | 3 ++ BZOJ/3629/data/6.out | 3 ++ BZOJ/3629/data/7.in | 3 ++ BZOJ/3629/data/7.out | 3 ++ BZOJ/3629/data/8.in | 3 ++ BZOJ/3629/data/8.out | 3 ++ BZOJ/3629/data/9.in | 3 ++ BZOJ/3629/data/9.out | 3 ++ 23 files changed, 145 insertions(+) create mode 100644 BZOJ/3629/3629.cpp create mode 100644 BZOJ/3629/data/1.in create mode 100644 BZOJ/3629/data/1.out create mode 100644 BZOJ/3629/data/10.in create mode 100644 BZOJ/3629/data/10.out create mode 100644 BZOJ/3629/data/11.in create mode 100644 BZOJ/3629/data/11.out create mode 100644 BZOJ/3629/data/2.in create mode 100644 BZOJ/3629/data/2.out create mode 100644 BZOJ/3629/data/3.in create mode 100644 BZOJ/3629/data/3.out create mode 100644 BZOJ/3629/data/4.in create mode 100644 BZOJ/3629/data/4.out create mode 100644 BZOJ/3629/data/5.in create mode 100644 BZOJ/3629/data/5.out create mode 100644 BZOJ/3629/data/6.in create mode 100644 BZOJ/3629/data/6.out create mode 100644 BZOJ/3629/data/7.in create mode 100644 BZOJ/3629/data/7.out create mode 100644 BZOJ/3629/data/8.in create mode 100644 BZOJ/3629/data/8.out create mode 100644 BZOJ/3629/data/9.in create mode 100644 BZOJ/3629/data/9.out diff --git a/BZOJ/3629/3629.cpp b/BZOJ/3629/3629.cpp new file mode 100644 index 00000000..1f9039ed --- /dev/null +++ b/BZOJ/3629/3629.cpp @@ -0,0 +1,79 @@ +#include +#include + +using std::cin; +using std::cout; +const char endl = '\n'; + +int cnt; +long long s, ans[500005]; +int p, primes[50005]; +bool not_prime[50005]; + +bool is_prime(long long x) { + if (x < 2) return false; + + for (int i = 2; static_cast(i) * i <= x; i++) { + if (x % i == 0) return false; + } + + return true; +} + +void dfs(long long now, int pos, long long sum) { + if (now == 1) { + ans[++cnt] = sum; + + return; + } + + if (is_prime(now - 1) && now > primes[pos]) { + ans[++cnt] = (now - 1) * sum; + } + + for (int i = pos; + static_cast(primes[i]) * primes[i] <= now; + i++) { + for (long long t = primes[i], + s = t + 1; + s <= now; + s += t *= primes[i]) { + if (now % s == 0) { + dfs(now / s, i + 1, sum * t); + } + } + } +} + +int main() { + std::ios::sync_with_stdio(false); + cin.tie(nullptr); + + for (int i = 2; i <= 50000; i++) { + if (!not_prime[i]) primes[++p] = i; + + for (int j = 1; i * primes[j] <= 50000; j++) { + not_prime[i * primes[j]] = true; + if (i % primes[j] == 0) break; + } + } + + while (cin >> s) { + cnt = 0; + + dfs(s, 1, 1); + std::sort(ans + 1, ans + cnt + 1); + + cout << cnt << endl; + + if (cnt) { + for (int i = 1; i <= cnt; i++) { + cout << ans[i] << ' '; + } + + cout << endl; + } + } + + return 0; +} diff --git a/BZOJ/3629/data/1.in b/BZOJ/3629/data/1.in new file mode 100644 index 00000000..7cafb554 --- /dev/null +++ b/BZOJ/3629/data/1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:38ac240fe02847572d7e6767aa4a20449daed0ddb78c48a0c0c2ca787d8a1ab2 +size 119 diff --git a/BZOJ/3629/data/1.out b/BZOJ/3629/data/1.out new file mode 100644 index 00000000..bf2d3fe5 --- /dev/null +++ b/BZOJ/3629/data/1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:42696e5388207d7f187e6b2bad97cb84147fc1d5f2858da18b8fe03a6ee68146 +size 2043302 diff --git a/BZOJ/3629/data/10.in b/BZOJ/3629/data/10.in new file mode 100644 index 00000000..fb1aa2b4 --- /dev/null +++ b/BZOJ/3629/data/10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e28c7feebcf0542eaaf84b8648846970cf3c24024703bdc5e5eeb4daa2358994 +size 494 diff --git a/BZOJ/3629/data/10.out b/BZOJ/3629/data/10.out new file mode 100644 index 00000000..94f64e93 --- /dev/null +++ b/BZOJ/3629/data/10.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:23a675506f9beed9c105c4953705621436d22e947d658cbab86ce66681d9ab77 +size 9967 diff --git a/BZOJ/3629/data/11.in b/BZOJ/3629/data/11.in new file mode 100644 index 00000000..40f7ffcf --- /dev/null +++ b/BZOJ/3629/data/11.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:671fdcc43bdcd00cd4fbe5fb7c737ab94d1c9152e02d816fbf0ee76c6c44c814 +size 496 diff --git a/BZOJ/3629/data/11.out b/BZOJ/3629/data/11.out new file mode 100644 index 00000000..3aeaf859 --- /dev/null +++ b/BZOJ/3629/data/11.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:edc3c03d423f6c37e7b1151166d74ec1bec0bcfdbf4bd4a9e4db645c120178ae +size 439 diff --git a/BZOJ/3629/data/2.in b/BZOJ/3629/data/2.in new file mode 100644 index 00000000..a434311a --- /dev/null +++ b/BZOJ/3629/data/2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bb225be1ecde9bbc8232ae65bf0c0c5ca4451ba973e7c08cea569f9d68f94bd3 +size 491 diff --git a/BZOJ/3629/data/2.out b/BZOJ/3629/data/2.out new file mode 100644 index 00000000..7e47c46d --- /dev/null +++ b/BZOJ/3629/data/2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2c3b633fe2b4532fb001413eb2841929fab368001e34c0266b1c048b857e46dc +size 128208 diff --git a/BZOJ/3629/data/3.in b/BZOJ/3629/data/3.in new file mode 100644 index 00000000..1316ea53 --- /dev/null +++ b/BZOJ/3629/data/3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4649f73532c28f3d4a01d2a88da58ef45dfaa70ce5e368387967bacbe771b37f +size 492 diff --git a/BZOJ/3629/data/3.out b/BZOJ/3629/data/3.out new file mode 100644 index 00000000..9e78ac19 --- /dev/null +++ b/BZOJ/3629/data/3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8c9b52fd92526a7cba87fef0de1f9244eb9fd46c2f10d342c076f06f567d9f71 +size 523 diff --git a/BZOJ/3629/data/4.in b/BZOJ/3629/data/4.in new file mode 100644 index 00000000..7cc14377 --- /dev/null +++ b/BZOJ/3629/data/4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9f875d1e919d8e6e91e91a3c1b5becd25ee193feff3871b41dcd24c51cd99bba +size 296 diff --git a/BZOJ/3629/data/4.out b/BZOJ/3629/data/4.out new file mode 100644 index 00000000..d07bf3f0 --- /dev/null +++ b/BZOJ/3629/data/4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:776dc361a71fcce2b95098ed97973d384f932a8435db837998928eeb9c1b345e +size 1510 diff --git a/BZOJ/3629/data/5.in b/BZOJ/3629/data/5.in new file mode 100644 index 00000000..c220569f --- /dev/null +++ b/BZOJ/3629/data/5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f096ded9f95ccdc0a308826f9690695a6b0405f78b0d707577a0b206c4aa9c88 +size 492 diff --git a/BZOJ/3629/data/5.out b/BZOJ/3629/data/5.out new file mode 100644 index 00000000..7554f2af --- /dev/null +++ b/BZOJ/3629/data/5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:acb0aa3a6d379e940cd224d1e0f7bb0a8021b01add94e1f36b505e8c500ea448 +size 522 diff --git a/BZOJ/3629/data/6.in b/BZOJ/3629/data/6.in new file mode 100644 index 00000000..8450c93e --- /dev/null +++ b/BZOJ/3629/data/6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3607d82626aba4c3b4c7e287be074e6ab4649678c8208c5949419e2ae27e6785 +size 497 diff --git a/BZOJ/3629/data/6.out b/BZOJ/3629/data/6.out new file mode 100644 index 00000000..c98e3da5 --- /dev/null +++ b/BZOJ/3629/data/6.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:06d1e99516c41efd548daf3b6037fcd98c9bf195432dff69a8cf1e886dec983e +size 16081 diff --git a/BZOJ/3629/data/7.in b/BZOJ/3629/data/7.in new file mode 100644 index 00000000..19b154b3 --- /dev/null +++ b/BZOJ/3629/data/7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7fcb6e14cff356c4a1134908cff3e565f9168bc43e758d3659654e489067b134 +size 295 diff --git a/BZOJ/3629/data/7.out b/BZOJ/3629/data/7.out new file mode 100644 index 00000000..b8487f06 --- /dev/null +++ b/BZOJ/3629/data/7.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:874d1ac0b088d76368c22810140d43644a13c8ad74c9630a2963a045df45fb4e +size 3331 diff --git a/BZOJ/3629/data/8.in b/BZOJ/3629/data/8.in new file mode 100644 index 00000000..3c4c505d --- /dev/null +++ b/BZOJ/3629/data/8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5ef71be34c96d90f4c01a4479b8a3ffd25c9c71ec72189ab72eeab8662d99567 +size 296 diff --git a/BZOJ/3629/data/8.out b/BZOJ/3629/data/8.out new file mode 100644 index 00000000..a11b6b23 --- /dev/null +++ b/BZOJ/3629/data/8.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fec283ce89a9bb0756591d669a75cd5add1b39c16966a0adcf17c6618728d9dd +size 1437 diff --git a/BZOJ/3629/data/9.in b/BZOJ/3629/data/9.in new file mode 100644 index 00000000..4637e41c --- /dev/null +++ b/BZOJ/3629/data/9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2c3beb677e5fb0600620598a899f742b3d7378a210126d5032ea2201dfec8850 +size 298 diff --git a/BZOJ/3629/data/9.out b/BZOJ/3629/data/9.out new file mode 100644 index 00000000..194f1a47 --- /dev/null +++ b/BZOJ/3629/data/9.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0c33502afd96cdf0bcc69e44f858acd2bc10912fcac5fffe81392477de8468cd +size 3367