This documentation is automatically generated by online-judge-tools/verification-helper
View the Project on GitHub gtnao/algorithm
#define PROBLEM \ "https://onlinejudge.u-aizu.ac.jp/courses/library/6/NTL/1/NTL_1_A" #include <bits/stdc++.h> using namespace std; #include "../../src/math/prime_factor.hpp" int main() { int n; cin >> n; auto res = prime_factor(n); cout << n << ":"; for (auto p : res) { for (int i = 0; i < p.second; ++i) { cout << " " << p.first; } } cout << endl; return 0; }
#line 1 "test/aoj/ntl_1_a.test.cpp" #define PROBLEM \ "https://onlinejudge.u-aizu.ac.jp/courses/library/6/NTL/1/NTL_1_A" #include <bits/stdc++.h> using namespace std; #line 2 "src/math/prime_factor.hpp" #line 4 "src/math/prime_factor.hpp" using namespace std; template <typename T = long long> map<T, T> prime_factor(T n) { map<T, T> res; for (T i = 2; i * i <= n; ++i) { while (n % i == 0) { ++res[i]; n /= i; } } if (n != 1) { res[n] = 1; } return res; } #line 8 "test/aoj/ntl_1_a.test.cpp" int main() { int n; cin >> n; auto res = prime_factor(n); cout << n << ":"; for (auto p : res) { for (int i = 0; i < p.second; ++i) { cout << " " << p.first; } } cout << endl; return 0; }