Submission #958623

#TimeUsernameProblemLanguageResultExecution timeMemory
958623LucaIlieToys (CEOI18_toy)C++17
0 / 100
1 ms348 KiB
#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 (stderr)

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++ ) {
      |                      ~~^~~~~~~~~~~~~
#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...