cp_library

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

View the Project on GitHub downerkei/cp_library

:heavy_check_mark: verify/aoj/aoj_ntl_1_a.test.cpp

Depends on

Code

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

#include <bits/stdc++.h>
using namespace std;

#include "../../math/factorize.hpp"

int main() {
    int N;
    cin >> N;
    auto primes = factorize(N);
    cout << N << ':';
    for(auto [p, e] : primes) {
        while(e--) {
            cout << ' ' << p;
        }
    }
    cout << endl;

    return 0;
}
#line 1 "verify/aoj/aoj_ntl_1_a.test.cpp"
#define PROBLEM "https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=NTL_1_A&lang=ja"

#include <bits/stdc++.h>
using namespace std;

#line 1 "math/factorize.hpp"
vector<pair<long long, int>> factorize(long long N) {
    assert(0 < N);
    vector<pair<long long, int>> ret;
    for(long long p = 2; p * p <= N; p++) {
        if(N % p != 0) continue;
        int e = 0;
        while(N % p == 0) {
            N /= p;
            e++;
        }
        ret.push_back({p, e});
    }
    if(N != 1) ret.push_back({N, 1});
    return ret;
}
#line 7 "verify/aoj/aoj_ntl_1_a.test.cpp"

int main() {
    int N;
    cin >> N;
    auto primes = factorize(N);
    cout << N << ':';
    for(auto [p, e] : primes) {
        while(e--) {
            cout << ' ' << p;
        }
    }
    cout << endl;

    return 0;
}
Back to top page