Submission #3838627


Source Code Expand

Copy
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    lli N, P;
    cin >> N >> P;
    map<lli, lli> mp;
    lli p = P;
    for (lli i = 2; i * i <= P; i++) {
        while (p % i == 0) {
            mp[i]++;
            p /= i;
        }
    }
    mp[p]++;

    lli ans = 1;
    for (auto &it : mp) {
        if (it.second >= N) {
            ans *= it.first;
        }
    }

    cout << ans << endl;

    return 0;
}

Submission Info

Submission Time
Task C - Product and GCD
User commy
Language C++14 (GCC 5.4.1)
Score 0
Code Size 972 Byte
Status
Exec Time 12 ms
Memory 256 KB

Test Cases

Set Name Score / Max Score Test Cases
Sample 0 / 0 sample1.txt, sample2.txt, sample3.txt, sample4.txt
All 0 / 300 sample1.txt, sample2.txt, sample3.txt, sample4.txt, 1.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 2.txt, 20.txt, 21.txt, 22.txt, 23.txt, 24.txt, 25.txt, 26.txt, 3.txt, 4.txt, 5.txt, 6.txt, 7.txt, 8.txt, 9.txt, sample1.txt, sample2.txt, sample3.txt, sample4.txt
Case Name Status Exec Time Memory
1.txt 8 ms 256 KB
10.txt 3 ms 256 KB
11.txt 3 ms 256 KB
12.txt 11 ms 256 KB
13.txt 6 ms 256 KB
14.txt 10 ms 256 KB
15.txt 6 ms 256 KB
16.txt 9 ms 256 KB
17.txt 9 ms 256 KB
18.txt 9 ms 256 KB
19.txt 11 ms 256 KB
2.txt 8 ms 256 KB
20.txt 11 ms 256 KB
21.txt 4 ms 256 KB
22.txt 6 ms 256 KB
23.txt 9 ms 256 KB
24.txt 1 ms 256 KB
25.txt 12 ms 256 KB
26.txt 9 ms 256 KB
3.txt 10 ms 256 KB
4.txt 9 ms 256 KB
5.txt 11 ms 256 KB
6.txt 9 ms 256 KB
7.txt 11 ms 256 KB
8.txt 12 ms 256 KB
9.txt 9 ms 256 KB
sample1.txt 1 ms 256 KB
sample2.txt 1 ms 256 KB
sample3.txt 1 ms 256 KB
sample4.txt 12 ms 256 KB