답안 #927863

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
927863 2024-02-15T12:22:57 Z Regulus Toys (CEOI18_toy) C++17
0 / 100
0 ms 348 KB
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(false);cin.tie(0);
#define debug(x) cerr << #x << " = " << (x) << ' '
#define bug(x) cerr << (x) << ' '
#define endl cerr << '\n'
#define all(v) (v).begin(), (v).end()
#define SZ(v) (ll)(v).size()
#define lowbit(x) (x)&-(x)
#define pb emplace_back
#define F first
#define S second
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;

const int Mxm = 10000;
int prime[Mxm+5];
vector<int> p, v, ans;

inline void sieve()
{
    for (int i=2; i <= Mxm; ++i) prime[i] = i;
    for (int i=2; i <= Mxm; ++i)
    {
        if (prime[i] == i) p.pb(i);
        for (ll j : p)
        {
            if (i*j > Mxm) break;
            prime[i * j] = j;
            if (!(i % j)) break;
        }
    }
}

int main(void)
{ IO
    int n, i;

    cin >> n;
    sieve();
    int cur = n, m = sqrt(n);
    for (i=2; i <= m; ++i)
    {
        while (!(cur % i))
        {
            v.pb(i);
            cur /= i;
        }
    }
    if (cur > 1) v.pb(cur);

    for (int s=0; s < (1 << (SZ(v)-1)); ++s)
    {
        cur = v[0];
        int sum = 0;
        for (int i=0; i < SZ(v)-1; ++i)
        {
            if ((s >> i) & 1)
            {
                sum += cur - 1;
                cur = 1;
            }
            cur *= v[i+1];
        }
        sum += cur - 1;
        ans.pb(sum);
    }

    sort(all(ans));
    cout << SZ(ans) << '\n';
    for (int x : ans) cout << x << ' ';
    cout << '\n';

    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -