# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
714435 | stevancv | Toys (CEOI18_toy) | C++14 | 2949 ms | 4448 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define sp ' '
#define en '\n'
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
using namespace std;
const int N = 1e5 + 2;
const int M = 1e6 + 2;
const ll linf = 1e18;
vector<int> d;
set<int> ans;
int kolko;
void Resi(int i, int n, int s) {
if (n == 1) {
ans.insert(s);
kolko++;
return;
}
if (i == d.size() || n < d[i]) return;
if (n % d[i] == 0) Resi(i, n / d[i], s + d[i] - 1);
Resi(i + 1, n, s);
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
int n; cin >> n;
for (int i = 2; i * i <= n; i++) {
if (n % i == 0) {
d.push_back(i);
if (i * i != n) d.push_back(n / i);
}
}
d.push_back(n);
sort(d.begin(), d.end());
Resi(0, n, 0);
cout << ans.size() << en;
for (int i : ans) cout << i << sp;
cout << en;
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... |