Submission #1090892

# Submission time Handle Problem Language Result Execution time Memory
1090892 2024-09-19T05:20:27 Z vjudge1 Toys (CEOI18_toy) C++14
0 / 100
166 ms 262144 KB
// [CEOI2018] toys
#include <bits/stdc++.h>
using namespace std;
vector<int> F;
set<int> A;
void dfs(int li, const int s, const int n) {
  if (n == 1) A.insert(s);
  for (size_t i = li; i < F.size() and F[i] <= n; ++i)
    if (n % F[i] == 0) dfs(i, s + F[i] - 1, n / F[i]);
}
int main() {
  ios::sync_with_stdio(false), cin.tie(0);
  int n;
  cin >> n;
  for (int i = 2; i * i <= n; i++) {
    if (n % i) continue;
    F.push_back(i);  // 计算所有约数
    if (n % i != i) F.push_back(n / i);
  }
  F.push_back(n), sort(begin(F), end(F));
  dfs(0, 0, n);
  cout << A.size() << "\n";
  for (int a : A) cout << a << " ";
  return 0;
}
// ❓❓ 0
# Verdict Execution time Memory Grader output
1 Runtime error 166 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 166 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 166 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 166 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 166 ms 262144 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -