| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 688561 | four_specks | Toys (CEOI18_toy) | C++17 | 1942 ms | 4444 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
namespace
{
template <typename Fun>
struct YCombinator
{
template <typename T>
YCombinator(T &&_fun) : fun(forward<T>(_fun)) {}
template <typename... Args>
decltype(auto) operator()(Args &&...args) { return fun(ref(*this), forward<Args>(args)...); }
private:
Fun fun;
};
template <typename T>
YCombinator(T &&) -> YCombinator<decay_t<T>>;
} // namespace
void solve()
{
int n;
cin >> n;
vector res = YCombinator(
[&](auto self, int x, int g) -> vector<int>
{
vector<int> ret;
ret.push_back(x - 1);
for (int f = g; f * f <= x; f++)
{
if (x % f == 0)
{
{
vector cur = self(x / f, f);
for (int z : cur)
ret.push_back(z + f - 1);
}
if (f * f != x)
{
int y = x / f;
vector cur = self(f, y);
for (int z : cur)
ret.push_back(z + y - 1);
}
}
}
sort(ret.begin(), ret.end());
ret.erase(unique(ret.begin(), ret.end()), ret.end());
return ret;
})(n, 2);
cout << (int)res.size() << '\n';
for (int x : res)
cout << x << ' ';
cout << '\n';
}
int main()
{
ios_base::sync_with_stdio(false), cin.tie(NULL);
solve();
return 0;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
