0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-09-16 19:45:24 +00:00

3629. [JLOI2014] 聪明的燕姿

https://hydro.ac/d/bzoj/record/63a4610db053be17396a0964
This commit is contained in:
Baoshuo Ren 2022-12-22 21:53:02 +08:00
parent 6c1c09faf2
commit c26bcdc9f7
Signed by: baoshuo
GPG Key ID: 00CB9680AB29F51A
23 changed files with 145 additions and 0 deletions

79
BZOJ/3629/3629.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
BZOJ/3629/data/1.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3629/data/1.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3629/data/10.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3629/data/10.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3629/data/11.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3629/data/11.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3629/data/2.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3629/data/2.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3629/data/3.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3629/data/3.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3629/data/4.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3629/data/4.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3629/data/5.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3629/data/5.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3629/data/6.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3629/data/6.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3629/data/7.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3629/data/7.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3629/data/8.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3629/data/8.out (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3629/data/9.in (Stored with Git LFS) Normal file

Binary file not shown.

BIN
BZOJ/3629/data/9.out (Stored with Git LFS) Normal file

Binary file not shown.