diff --git a/LibreOJ/2234/2234.cpp b/LibreOJ/2234/2234.cpp new file mode 100644 index 00000000..1f9039ed --- /dev/null +++ b/LibreOJ/2234/2234.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/LibreOJ/2234/data/swallow1.in b/LibreOJ/2234/data/swallow1.in new file mode 100644 index 00000000..7cafb554 --- /dev/null +++ b/LibreOJ/2234/data/swallow1.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:38ac240fe02847572d7e6767aa4a20449daed0ddb78c48a0c0c2ca787d8a1ab2 +size 119 diff --git a/LibreOJ/2234/data/swallow1.out b/LibreOJ/2234/data/swallow1.out new file mode 100644 index 00000000..bf2d3fe5 --- /dev/null +++ b/LibreOJ/2234/data/swallow1.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:42696e5388207d7f187e6b2bad97cb84147fc1d5f2858da18b8fe03a6ee68146 +size 2043302 diff --git a/LibreOJ/2234/data/swallow10.in b/LibreOJ/2234/data/swallow10.in new file mode 100644 index 00000000..fb1aa2b4 --- /dev/null +++ b/LibreOJ/2234/data/swallow10.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:e28c7feebcf0542eaaf84b8648846970cf3c24024703bdc5e5eeb4daa2358994 +size 494 diff --git a/LibreOJ/2234/data/swallow10.out b/LibreOJ/2234/data/swallow10.out new file mode 100644 index 00000000..94f64e93 --- /dev/null +++ b/LibreOJ/2234/data/swallow10.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:23a675506f9beed9c105c4953705621436d22e947d658cbab86ce66681d9ab77 +size 9967 diff --git a/LibreOJ/2234/data/swallow11.in b/LibreOJ/2234/data/swallow11.in new file mode 100644 index 00000000..a434311a --- /dev/null +++ b/LibreOJ/2234/data/swallow11.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:bb225be1ecde9bbc8232ae65bf0c0c5ca4451ba973e7c08cea569f9d68f94bd3 +size 491 diff --git a/LibreOJ/2234/data/swallow11.out b/LibreOJ/2234/data/swallow11.out new file mode 100644 index 00000000..7e47c46d --- /dev/null +++ b/LibreOJ/2234/data/swallow11.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2c3b633fe2b4532fb001413eb2841929fab368001e34c0266b1c048b857e46dc +size 128208 diff --git a/LibreOJ/2234/data/swallow2.in b/LibreOJ/2234/data/swallow2.in new file mode 100644 index 00000000..40f7ffcf --- /dev/null +++ b/LibreOJ/2234/data/swallow2.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:671fdcc43bdcd00cd4fbe5fb7c737ab94d1c9152e02d816fbf0ee76c6c44c814 +size 496 diff --git a/LibreOJ/2234/data/swallow2.out b/LibreOJ/2234/data/swallow2.out new file mode 100644 index 00000000..3aeaf859 --- /dev/null +++ b/LibreOJ/2234/data/swallow2.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:edc3c03d423f6c37e7b1151166d74ec1bec0bcfdbf4bd4a9e4db645c120178ae +size 439 diff --git a/LibreOJ/2234/data/swallow3.in b/LibreOJ/2234/data/swallow3.in new file mode 100644 index 00000000..c220569f --- /dev/null +++ b/LibreOJ/2234/data/swallow3.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:f096ded9f95ccdc0a308826f9690695a6b0405f78b0d707577a0b206c4aa9c88 +size 492 diff --git a/LibreOJ/2234/data/swallow3.out b/LibreOJ/2234/data/swallow3.out new file mode 100644 index 00000000..7554f2af --- /dev/null +++ b/LibreOJ/2234/data/swallow3.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:acb0aa3a6d379e940cd224d1e0f7bb0a8021b01add94e1f36b505e8c500ea448 +size 522 diff --git a/LibreOJ/2234/data/swallow4.in b/LibreOJ/2234/data/swallow4.in new file mode 100644 index 00000000..1316ea53 --- /dev/null +++ b/LibreOJ/2234/data/swallow4.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:4649f73532c28f3d4a01d2a88da58ef45dfaa70ce5e368387967bacbe771b37f +size 492 diff --git a/LibreOJ/2234/data/swallow4.out b/LibreOJ/2234/data/swallow4.out new file mode 100644 index 00000000..9e78ac19 --- /dev/null +++ b/LibreOJ/2234/data/swallow4.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:8c9b52fd92526a7cba87fef0de1f9244eb9fd46c2f10d342c076f06f567d9f71 +size 523 diff --git a/LibreOJ/2234/data/swallow5.in b/LibreOJ/2234/data/swallow5.in new file mode 100644 index 00000000..3c4c505d --- /dev/null +++ b/LibreOJ/2234/data/swallow5.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:5ef71be34c96d90f4c01a4479b8a3ffd25c9c71ec72189ab72eeab8662d99567 +size 296 diff --git a/LibreOJ/2234/data/swallow5.out b/LibreOJ/2234/data/swallow5.out new file mode 100644 index 00000000..a11b6b23 --- /dev/null +++ b/LibreOJ/2234/data/swallow5.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:fec283ce89a9bb0756591d669a75cd5add1b39c16966a0adcf17c6618728d9dd +size 1437 diff --git a/LibreOJ/2234/data/swallow6.in b/LibreOJ/2234/data/swallow6.in new file mode 100644 index 00000000..7cc14377 --- /dev/null +++ b/LibreOJ/2234/data/swallow6.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:9f875d1e919d8e6e91e91a3c1b5becd25ee193feff3871b41dcd24c51cd99bba +size 296 diff --git a/LibreOJ/2234/data/swallow6.out b/LibreOJ/2234/data/swallow6.out new file mode 100644 index 00000000..d07bf3f0 --- /dev/null +++ b/LibreOJ/2234/data/swallow6.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:776dc361a71fcce2b95098ed97973d384f932a8435db837998928eeb9c1b345e +size 1510 diff --git a/LibreOJ/2234/data/swallow7.in b/LibreOJ/2234/data/swallow7.in new file mode 100644 index 00000000..19b154b3 --- /dev/null +++ b/LibreOJ/2234/data/swallow7.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:7fcb6e14cff356c4a1134908cff3e565f9168bc43e758d3659654e489067b134 +size 295 diff --git a/LibreOJ/2234/data/swallow7.out b/LibreOJ/2234/data/swallow7.out new file mode 100644 index 00000000..b8487f06 --- /dev/null +++ b/LibreOJ/2234/data/swallow7.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:874d1ac0b088d76368c22810140d43644a13c8ad74c9630a2963a045df45fb4e +size 3331 diff --git a/LibreOJ/2234/data/swallow8.in b/LibreOJ/2234/data/swallow8.in new file mode 100644 index 00000000..4637e41c --- /dev/null +++ b/LibreOJ/2234/data/swallow8.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:2c3beb677e5fb0600620598a899f742b3d7378a210126d5032ea2201dfec8850 +size 298 diff --git a/LibreOJ/2234/data/swallow8.out b/LibreOJ/2234/data/swallow8.out new file mode 100644 index 00000000..194f1a47 --- /dev/null +++ b/LibreOJ/2234/data/swallow8.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:0c33502afd96cdf0bcc69e44f858acd2bc10912fcac5fffe81392477de8468cd +size 3367 diff --git a/LibreOJ/2234/data/swallow9.in b/LibreOJ/2234/data/swallow9.in new file mode 100644 index 00000000..8450c93e --- /dev/null +++ b/LibreOJ/2234/data/swallow9.in @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:3607d82626aba4c3b4c7e287be074e6ab4649678c8208c5949419e2ae27e6785 +size 497 diff --git a/LibreOJ/2234/data/swallow9.out b/LibreOJ/2234/data/swallow9.out new file mode 100644 index 00000000..c98e3da5 --- /dev/null +++ b/LibreOJ/2234/data/swallow9.out @@ -0,0 +1,3 @@ +version https://git-lfs.github.com/spec/v1 +oid sha256:06d1e99516c41efd548daf3b6037fcd98c9bf195432dff69a8cf1e886dec983e +size 16081