# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
958627 | 2024-04-06T08:28:08 Z | LucaIlie | Toys (CEOI18_toy) | C++17 | 0 ms | 604 KB |
#include <bits/stdc++.h> using namespace std; const int MAX_DIVS = 10000; 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 / d ) 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 ), printf( "%d\n", 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
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 600 KB | Output is correct |
2 | Incorrect | 0 ms | 604 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 600 KB | Output is correct |
2 | Incorrect | 0 ms | 604 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 600 KB | Output is correct |
2 | Incorrect | 0 ms | 604 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 600 KB | Output is correct |
2 | Incorrect | 0 ms | 604 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 600 KB | Output is correct |
2 | Incorrect | 0 ms | 604 KB | Output isn't correct |
3 | Halted | 0 ms | 0 KB | - |