제출 #920779

#제출 시각아이디문제언어결과실행 시간메모리
920779Ghulam_JunaidToys (CEOI18_toy)C++17
79 / 100
2150 ms262144 KiB
#include <bits/stdc++.h>
using namespace std;

const int N = 2005;

int n;
vector<int> store[N];
unordered_map<int, int> id;
vector<int> divs, imp[N];

inline void F(int x){
    store[id[x]].push_back(x - 1);
    for (int d : imp[id[x]]){
        for (int a : store[id[d]])
            for (int b : store[id[x]])
                store[id[d * x]].push_back(a + b);
    }
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    cin >> n;

    for (int x = 2; x * x <= n; x ++){
        if (n % x) continue;
        divs.push_back(x);
        if (x * x != n)
            divs.push_back(n / x);
    }
    divs.push_back(n);

    sort(divs.begin(), divs.end());  
    for (int i = 0; i < divs.size(); i ++){
        id[divs[i]] = i;
        for (int j = 0; j <= i; j ++){
            long long prod = 1ll * divs[i] * divs[j];
            if (prod > n)
                break;
            if (n % prod == 0)
                imp[id[divs[i]]].push_back(divs[j]);
        }
    }

    for (int x : divs){
        sort(store[id[x]].begin(), store[id[x]].end());
        store[id[x]].resize(unique(store[id[x]].begin(), store[id[x]].end()) - store[id[x]].begin());
        F(x);
    }

    if (n == 1) store[id[n]] = {0};
    cout << store[id[n]].size() << endl;
    for (int x : store[id[n]])
        cout << x << " ";
    cout << '\n';
}

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

toy.cpp: In function 'int main()':
toy.cpp:35:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |     for (int i = 0; i < divs.size(); i ++){
      |                     ~~^~~~~~~~~~~~~
#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...