kyopro-lib

This documentation is automatically generated by online-judge-tools/verification-helper

View on GitHub

:x: test/aoj/NTL_1_A/main.test.cpp

Depends on

Code

#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_A"

#include <iostream>
#include "Mylib/Number/Prime/prime_factorize.cpp"

namespace hl = haar_lib;

int main() {
  int n;
  std::cin >> n;

  auto res = hl::prime_factorize(n);

  std::cout << n << ":";

  for (auto& [x, c] : res) {
    for (int i = 0; i < c; ++i) {
      std::cout << " " << x;
    }
  }

  std::cout << std::endl;

  return 0;
}
#line 1 "test/aoj/NTL_1_A/main.test.cpp"
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_A"

#include <iostream>
#line 2 "Mylib/Number/Prime/prime_factorize.cpp"
#include <cstdint>
#include <utility>
#include <vector>

namespace haar_lib {
  auto prime_factorize(int64_t n) -> std::vector<std::pair<int64_t, int64_t>> {
    std::vector<std::pair<int64_t, int64_t>> ret;
    for (int64_t i = 2LL; i * i <= n; ++i) {
      if (n % i == 0) {
        int64_t c = 0;
        while (n % i == 0) {
          n /= i;
          ++c;
        }
        ret.emplace_back(i, c);
      }
    }
    if (n != 1) ret.emplace_back(n, 1);
    return ret;
  }
}  // namespace haar_lib
#line 5 "test/aoj/NTL_1_A/main.test.cpp"

namespace hl = haar_lib;

int main() {
  int n;
  std::cin >> n;

  auto res = hl::prime_factorize(n);

  std::cout << n << ":";

  for (auto& [x, c] : res) {
    for (int i = 0; i < c; ++i) {
      std::cout << " " << x;
    }
  }

  std::cout << std::endl;

  return 0;
}
Back to top page