답안 #581704

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
581704 2022-06-23T04:14:29 Z Memito08 Toys (CEOI18_toy) C++14
0 / 100
0 ms 212 KB
#include <bits/stdc++.h>

using namespace std;

vector<int> sumas;
long long sum = 0;
vector<bool> u;

void solve(long long n, int act) {
    if (n == 1 && !u[sum]) {
        sumas.push_back(sum);
        u[sum] = 1;
        return;
    }
    for (int i = act ; i*i <= n ; i++) {
        if (n % i == 0) {
            sum += i-1;
            solve(n/i,i);
            sum -= i-1;
        }
    }
    if (n > 1) {
        sum += n-1;
        solve(1,n);
        sum -= n-1;
    }
}

int main() {
    long long n;
    cin >> n;
    u.assign(n, 0);
    solve(n, 2);
    sort(sumas.begin(),sumas.end());
    
    for (int i = 0 ; i < sumas.size() ; i++) {
        cout << sumas[i];
        if (i != sumas.size()-1) cout << " ";
    }
    
    cout << "\n";

    return 0;
}

Compilation message

toy.cpp: In function 'int main()':
toy.cpp:36:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for (int i = 0 ; i < sumas.size() ; i++) {
      |                      ~~^~~~~~~~~~~~~~
toy.cpp:38:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         if (i != sumas.size()-1) cout << " ";
      |             ~~^~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 212 KB Output isn't correct
2 Halted 0 ms 0 KB -