제출 #1260803

#제출 시각아이디문제언어결과실행 시간메모리
1260803icebearToys (CEOI18_toy)C++20
79 / 100
5096 ms73476 KiB
// ~~ icebear ~~
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;

template<class T>
    bool minimize(T &a, const T &b) {
        if (a > b) return a = b, true;
        return false;
    }

template<class T>
    bool maximize(T &a, const T &b) {
        if (a < b) return a = b, true;
        return false;
    }

#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORR(i,a,b) for(int i=(a); i>=(b); --i)
#define REP(i, n) for(int i=0; i<(n); ++i)
#define RED(i, n) for(int i=(n)-1; i>=0; --i)
#define MASK(i) (1LL << (i))
#define BIT(S, i) (((S) >> (i)) & 1)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define task "icebear"

const int MOD = 1e9 + 7;
const int inf = 1e9 + 27092008;
const ll INF = 1e18 + 27092008;
const int N = 2e5 + 5;
int n;
set<int> dp[1500];

void init(void) {
    cin >> n;
}

void process(void) {
    vector<int> divs;
    for(int i = 1; i * i <= n; i++) {
        if (n % i == 0) divs.pb(i);
        if (n % i == 0 && i * i != n) divs.pb(n / i);
    }
    sort(all(divs));
    map<int, int> id;

    int num = (int)divs.size();
    REP(i, num) id[divs[i]] = i;
    REP(i, num) {
        dp[i].insert(divs[i] - 1); // i = i * 1
        REP(j, i) {
            if (divs[i] % divs[j] == 0) {
                int x = id[divs[i] / divs[j]];
                for(int s1 : dp[j]) for(int s2 : dp[x])
                    dp[i].insert(s1 + s2); // i = x * y
            }
            if (1ll * divs[j] * divs[j] > divs[i]) break;
        }
    }

    cout << dp[num - 1].size() << '\n';
    for(int ans : dp[num - 1]) cout << ans << ' ';
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    if (fopen(task".inp", "r")) {
        freopen(task".inp", "r", stdin);
        freopen(task".out", "w", stdout);
    }
    int tc = 1;
//    cin >> tc;
    while(tc--) {
        init();
        process();
    }
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

toy.cpp: In function 'int main()':
toy.cpp:76:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   76 |         freopen(task".inp", "r", stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~
toy.cpp:77:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   77 |         freopen(task".out", "w", stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...