# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
1029366 |
2024-07-20T19:00:25 Z |
NValchanov |
Toys (CEOI18_toy) |
C++17 |
|
0 ms |
348 KB |
#include <bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long ll;
const ll MAXN = 1e9 + 10;
unordered_map < ll, unordered_map < ll, bool > > dp;
ll n, m;
vector < ll > divs;
void read()
{
cin >> n;
}
void fill_divs()
{
for(ll i = 2; i * i <= n; i++)
{
if(n % i == 0)
{
divs.push_back(i);
if(i * i != n)
divs.push_back(n / i);
}
}
divs.push_back(n);
m = divs.size();
sort(divs.begin(), divs.end());
}
void rec(ll cur, ll sum, ll last)
{
if(dp[cur][sum])
return;
dp[cur][sum] = true;
if(cur == n)
return;
for(ll i = last; i < m; i++)
{
ll d = divs[i];
if(cur * d > n)
continue;
if(!dp[cur * d][sum + d - 1])
rec(cur * d, sum + d - 1, i);
}
}
void print()
{
cout << dp[n].size() << endl;
for(auto x : dp[n])
{
cout << x.first << " ";
}
cout << endl;
}
int main()
{
ios_base :: sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
read();
fill_divs();
rec(1, 0, 0);
print();
return 0;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
348 KB |
Output is correct |
4 |
Incorrect |
0 ms |
348 KB |
Output isn't correct |
5 |
Halted |
0 ms |
0 KB |
- |