답안 #679903

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
679903 2023-01-09T15:55:35 Z peijar Toys (CEOI18_toy) C++17
0 / 100
0 ms 212 KB
#include <bits/extc++.h>
#include <bits/stdc++.h>
#define int long long
using namespace std;

namespace std {
template <typename T> ostream &operator<<(ostream &out, const vector<T> &vec) {
  out << "[";
  for (int i = 0; i < (int)vec.size(); ++i) {
    out << vec[i];
    if (i + 1 < (int)vec.size())
      out << ", ";
  }
  return out << "]";
}
} // namespace std

void dbg_out() { cout << endl; }
template <typename Head, typename... Tail> void dbg_out(Head H, Tail... T) {
  cout << ' ' << H;
  dbg_out(T...);
}

#ifdef DEBUG
#define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__)
#else
#define dbg(...)
#endif

// To use most b i t s rather than j u s t the lowest ones :
struct chash { // large odd number for C
  const uint64_t C = (int)(4e18 * acos(0)) | 71;
  int operator()(int x) const { return __builtin_bswap64(x * C); }
};

using hash_table = __gnu_pbds::gp_hash_table<int, int, chash>;
using hash_set = __gnu_pbds::gp_hash_table<int, __gnu_pbds::null_type, chash>;

signed main(void) {
  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int n;
  cin >> n;
  vector<int> diviseurs;
  for (int d = 1; d * d <= n; d++) {
    if (n % d == 0) {
      diviseurs.push_back(d);
      if (d * d != n)
        diviseurs.push_back(n / d);
    }
  }

  sort(diviseurs.begin(), diviseurs.end());

  int nbDiviseurs = diviseurs.size();
  hash_table idDiv;
  for (int i = 0; i < nbDiviseurs; ++i)
    idDiv[diviseurs[i]] = i;
  vector<hash_set> possibilites(nbDiviseurs);
  for (int i = 0; i < nbDiviseurs; ++i) {
    int d = diviseurs[i];
    possibilites[i].insert(d - 1);
    for (int j = i + 1; j < nbDiviseurs; ++j)
      if (diviseurs[j] % d == 0) {
        int dd = diviseurs[j] / d;
        if (dd <= d)
          for (int q : possibilites[idDiv[dd]])
            possibilites[j].insert(q + d - 1);
      }
  }
  vector<int> ret;
  for (int x : possibilites[nbDiviseurs - 1])
    ret.push_back(x);
  sort(ret.begin(), ret.end());
  cout << ret.size() << endl;
  for (int x : ret)
    cout << x << ' ';
  cout << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Incorrect 0 ms 212 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Incorrect 0 ms 212 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Incorrect 0 ms 212 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Incorrect 0 ms 212 KB Output isn't correct
9 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 0 ms 212 KB Output is correct
3 Correct 0 ms 212 KB Output is correct
4 Correct 0 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 0 ms 212 KB Output is correct
7 Correct 0 ms 212 KB Output is correct
8 Incorrect 0 ms 212 KB Output isn't correct
9 Halted 0 ms 0 KB -