답안 #958623

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
958623 2024-04-06T08:24:23 Z LucaIlie Toys (CEOI18_toy) C++17
0 / 100
1 ms 348 KB
#include <bits/stdc++.h>

using namespace std;

const int MAX_DIVS = 1000;
vector<int> divs;
vector<int> sol[MAX_DIVS];

int main() {
    int n;

    cin >> n;

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

    sort( divs.begin(), divs.end() );

    sol[0].push_back( 0 );
    for ( int i = 1; i < divs.size(); i++ ) {
        int a = divs[i];
        for ( int j = 0; j < i; j++ ) {
            int b = divs[j];
            if ( a % b != 0 )
                continue;

            for ( int x: sol[j] )
                sol[i].push_back( x + a / b - 1 );
        }

        sort( sol[i].begin(), sol[i].end() );
        sol[i].resize( unique( sol[i].begin(), sol[i].end() ) - sol[i].begin() );
    }

    cout << sol[divs.size() - 1].size() << "\n";
    for ( int x: sol[divs.size() - 1] )
        cout << x  << " ";

    return 0;
}

Compilation message

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