Submission #161387

# Submission time Handle Problem Language Result Execution time Memory
161387 2019-11-02T07:09:02 Z rama_pang Toys (CEOI18_toy) C++14
0 / 100
2 ms 252 KB
#include <bits/stdc++.h>
using namespace std;
using lint = long long;

vector<int> factors;
set<lint> ans;

void brute_force(int n, vector<lint> elements) {
    if (n == factors.size()) {
        lint res = 0;
        for (auto i : elements) res += i;
        ans.emplace(res);
        return;
    }

    for (auto i = 0; i < elements.size(); i++) {
        lint tmp = elements[i];
        elements[i] = elements[i] * factors[n] + elements[i] + factors[n];
        brute_force(n + 1, elements);
        elements[i] = tmp;
    }   
    elements.push_back(factors[n]);
    brute_force(n + 1, elements);
    return;

}

int main() {
    int N; cin >> N;
    
    for (int i = 2; i <= N; i++) {
        while (N % i == 0) {
            factors.push_back(i - 1);
            N /= i;
        }
        if (i * i > N) {
            if (N > 1) factors.push_back(N - 1);
            brute_force(0, vector<lint>());
            break;
        }
    }
    
    cout << ans.size() << "\n";
    for (auto i : ans) cout << i << " ";

}

Compilation message

toy.cpp: In function 'void brute_force(int, std::vector<long long int>)':
toy.cpp:9:11: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     if (n == factors.size()) {
         ~~^~~~~~~~~~~~~~~~~
toy.cpp:16:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for (auto i = 0; i < elements.size(); i++) {
                      ~~^~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 252 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 252 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 252 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 252 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 252 KB Output isn't correct
2 Halted 0 ms 0 KB -