# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1179863 | CrabCNH | Toys (CEOI18_toy) | C++20 | 531 ms | 5752 KiB |
#include <bits/stdc++.h>
#define task "BriantheCrab"
#define int long long
#define pii pair <int, int>
#define fi first
#define se second
#define szf sizeof
#define sz(s) (int)((s).size())
using namespace std;
template <class T> void mini (T &t, T f) {if (t > f) t = f;}
template <class T> void maxi (T &t, T f) {if (t < f) t = f;}
const int maxN = 1e5 + 5;
const int inf = 1e18 + 7;
const int mod = 1e9 + 7;
int a[maxN];
vector <int> all;
map <int, int> mp;
void backtrack (int x, int cur, int sum) {
//cout << x << ' ' << cur << '\n';
if (x == 1) {
mp[sum] = 1;
return;
}
while (cur >= 0 && (x % all[cur] != 0)) {
cur --;
}
if (cur < 0) {
return;
}
backtrack (x, cur - 1, sum);
backtrack (x / all[cur], cur, sum + all[cur] - 1);
}
void solve () {
int n;
cin >> n;
for (int i = 2; i * i < n; i ++) {
if (n % i == 0) {
all.push_back (i);
all.push_back (n / i);
}
}
all.push_back (n);
if (sqrt (n) * (int) sqrt (n) == n) {
all.push_back (sqrt (n));
}
sort (all.begin (), all.end ());
backtrack (n, all.size () - 1, 0);
cout << mp.size () << '\n';
for (auto [u, _] : mp) {
cout << u << ' ';
}
}
signed main () {
cin.tie (nullptr) -> sync_with_stdio (false);
if (fopen (task".inp", "r")) {
freopen (task".inp", "r", stdin);
freopen (task".out", "w", stdout);
}
int t = 1;
//cin >> t;
while (t --) {
solve ();
}
return 0;
}
// thfdgb
컴파일 시 표준 에러 (stderr) 메시지
# | 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... |