0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-09 16:58:48 +00:00

#2234. 「JLOI2014」聪明的燕姿

https://loj.ac/s/1590596
This commit is contained in:
Baoshuo Ren 2022-10-01 09:15:49 +08:00
parent b4f738178b
commit 413432dbbf
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
23 changed files with 145 additions and 0 deletions

79
LibreOJ/2234/2234.cpp Normal file
View File

@ -0,0 +1,79 @@
#include <iostream>
#include <algorithm>
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<long long>(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<long long>(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;
}

BIN
LibreOJ/2234/data/swallow1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2234/data/swallow1.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2234/data/swallow10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2234/data/swallow10.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2234/data/swallow11.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2234/data/swallow11.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2234/data/swallow2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2234/data/swallow2.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2234/data/swallow3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2234/data/swallow3.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2234/data/swallow4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2234/data/swallow4.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2234/data/swallow5.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2234/data/swallow5.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2234/data/swallow6.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2234/data/swallow6.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2234/data/swallow7.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2234/data/swallow7.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2234/data/swallow8.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2234/data/swallow8.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2234/data/swallow9.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
LibreOJ/2234/data/swallow9.out (Stored with Git LFS) Normal file

Binary file not shown.