# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1260784 | icebear | Toys (CEOI18_toy) | C++20 | 2852 ms | 327680 KiB |
// ~~ icebear ~~
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef pair<int, ii> iii;
template<class T>
bool minimize(T &a, const T &b) {
if (a > b) return a = b, true;
return false;
}
template<class T>
bool maximize(T &a, const T &b) {
if (a < b) return a = b, true;
return false;
}
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORR(i,a,b) for(int i=(a); i>=(b); --i)
#define REP(i, n) for(int i=0; i<(n); ++i)
#define RED(i, n) for(int i=(n)-1; i>=0; --i)
#define MASK(i) (1LL << (i))
#define BIT(S, i) (((S) >> (i)) & 1)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define task "icebear"
const int MOD = 1e9 + 7;
const int inf = 1e9 + 27092008;
const ll INF = 1e18 + 27092008;
const int N = 2e5 + 5;
int n;
void init(void) {
cin >> n;
}
void process(void) {
vector<int> divs;
for(int i = 1; i * i <= n; i++) {
if (n % i == 0) divs.pb(i);
if (n % i == 0 && i * i != n) divs.pb(n / i);
}
sort(all(divs));
map<int, int> id;
int num = (int)divs.size();
vector<vector<int>> dp(num);
REP(i, num) id[divs[i]] = i;
REP(i, num) {
dp[i].push_back(divs[i] - 1); // i = i * 1
REP(j, i) if (divs[i] % divs[j] == 0) {
int x = id[divs[i] / divs[j]];
for(int &s1 : dp[j]) for(int &s2 : dp[x])
dp[i].push_back(s1 + s2); // i = x * y
}
sort(all(dp[i]));
dp[i].resize(unique(all(dp[i])) - dp[i].begin());
}
cout << dp[num - 1].size() << '\n';
for(int ans : dp[num - 1]) cout << ans << ' ';
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
if (fopen(task".inp", "r")) {
freopen(task".inp", "r", stdin);
freopen(task".out", "w", stdout);
}
int tc = 1;
// cin >> tc;
while(tc--) {
init();
process();
}
return 0;
}
컴파일 시 표준 에러 (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... |