problem_id
stringlengths 6
6
| language
stringclasses 2
values | original_status
stringclasses 3
values | original_src
stringlengths 19
243k
| changed_src
stringlengths 19
243k
| change
stringclasses 3
values | i1
int64 0
8.44k
| i2
int64 0
8.44k
| j1
int64 0
8.44k
| j2
int64 0
8.44k
| error
stringclasses 270
values | stderr
stringlengths 0
226k
|
---|---|---|---|---|---|---|---|---|---|---|---|
p03194 | C++ | Time Limit Exceeded | /// @file
#include <cmath>
#include <iostream>
namespace {
bool run(std::istream &is, std::ostream &os);
} // unnamed namespace
/// @brief エントリポイント
#ifdef _TEST
static int run()
#else
int main()
#endif
{
try {
if (run(std::cin, std::cout) == false) {
std::cerr << "main funciton error.\n";
return EXIT_FAILURE;
}
} catch (const std::exception &e) {
std::cerr << "catch exception\n";
std::cerr << e.what() << "\n";
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
namespace {
/// @brief 実行処理
bool run(std::istream &is, std::ostream &os) {
typedef long Num_t;
Num_t n;
Num_t p;
is >> n >> p;
// n 乗したときに p を超えない最大数を求める
Num_t maxNum(1);
for (; std::pow(maxNum, n) <= p; ++maxNum)
;
--maxNum;
// 最大数から逆側にあまりがなくなる値を求める
Num_t divisor(maxNum);
for (; divisor > 0; --divisor) {
if (p % static_cast<Num_t>(std::pow(divisor, n)) == 0)
break;
}
os << divisor << '\n';
return true;
}
} // unnamed namespace
| /// @file
#include <cmath>
#include <iostream>
namespace {
bool run(std::istream &is, std::ostream &os);
} // unnamed namespace
/// @brief エントリポイント
#ifdef _TEST
static int run()
#else
int main()
#endif
{
try {
if (run(std::cin, std::cout) == false) {
std::cerr << "main funciton error.\n";
return EXIT_FAILURE;
}
} catch (const std::exception &e) {
std::cerr << "catch exception\n";
std::cerr << e.what() << "\n";
return EXIT_FAILURE;
}
return EXIT_SUCCESS;
}
namespace {
/// @brief 実行処理
bool run(std::istream &is, std::ostream &os) {
typedef long Num_t;
Num_t n;
Num_t p;
is >> n >> p;
// n 乗したときに p を超えない最大数を求める
Num_t maxNum = static_cast<Num_t>(std::ceil(std::pow(p, 1.0 / n)));
// 最大数から逆側にあまりがなくなる値を求める
Num_t divisor(maxNum);
for (; divisor > 0; --divisor) {
if (p % static_cast<Num_t>(std::pow(divisor, n)) == 0)
break;
}
os << divisor << '\n';
return true;
}
} // unnamed namespace
| replace | 42 | 46 | 42 | 43 | TLE | |
p03194 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
#define ll int64_t
// ライブラリ始まり
// 定数
// 円周率
const double PI = 3.1415926535897932384;
// 天井
const int INF = 1000000000; // = 10^9
const ll LINF = 1000000000000000; // = 10^15
// ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";
// よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7
// 関数
// ctoi
int ctoi(char c) {
if (c == '0') {
return 0;
}
if (c == '1') {
return 1;
}
if (c == '2') {
return 2;
}
if (c == '3') {
return 3;
}
if (c == '4') {
return 4;
}
if (c == '5') {
return 5;
}
if (c == '6') {
return 6;
}
if (c == '7') {
return 7;
}
if (c == '8') {
return 8;
}
if (c == '9') {
return 9;
}
return -1;
}
// 素数判定
bool PN(int x) {
if (x <= 1) {
return false;
}
if (x == 2) {
return true;
}
for (int i = 2; i < sqrt(x) + 1; i++) {
if (x % i == 0) {
return false;
}
}
return true;
}
// ライブラリ終わり
int main() {
ll N, P;
cin >> N >> P;
ll ans = 1;
for (ll i = 1; i <= P; i++) {
ll K = pow(i, N);
if (K > P) {
break;
}
if (P % K == 0) {
ans = i;
}
}
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
#define ll int64_t
// ライブラリ始まり
// 定数
// 円周率
const double PI = 3.1415926535897932384;
// 天井
const int INF = 1000000000; // = 10^9
const ll LINF = 1000000000000000; // = 10^15
// ABC文字列
const string ABC = "ABCDEFGHIJKLMNOPQRSTUVWXYZABC";
const string abc = "abcdefghijklmnopqrstuvwxyzabc";
// よくあるmodくん
const ll MOD = 1000000007; // = 10^9 + 7
// 関数
// ctoi
int ctoi(char c) {
if (c == '0') {
return 0;
}
if (c == '1') {
return 1;
}
if (c == '2') {
return 2;
}
if (c == '3') {
return 3;
}
if (c == '4') {
return 4;
}
if (c == '5') {
return 5;
}
if (c == '6') {
return 6;
}
if (c == '7') {
return 7;
}
if (c == '8') {
return 8;
}
if (c == '9') {
return 9;
}
return -1;
}
// 素数判定
bool PN(int x) {
if (x <= 1) {
return false;
}
if (x == 2) {
return true;
}
for (int i = 2; i < sqrt(x) + 1; i++) {
if (x % i == 0) {
return false;
}
}
return true;
}
// ライブラリ終わり
int main() {
ll N, P;
cin >> N >> P;
ll ans = 1;
if (N == 1) {
ans = P;
} else {
for (ll i = 1; i <= sqrt(P) + 1; i++) {
ll K = pow(i, N);
if (K > P) {
break;
}
if (P % K == 0) {
ans = i;
}
}
}
cout << ans << endl;
} | replace | 81 | 88 | 81 | 92 | TLE | |
p03194 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
long long N, P;
cin >> N >> P;
long long temp;
bool flg;
for (long long i = pow(P, 1 / double(N)) + 1; i > 0; i--) {
temp = P;
flg = true;
for (long long j = 0; j < N; j++) {
if (temp % i == 0) {
temp = temp / i;
} else {
flg = false;
break;
}
}
if (flg) {
cout << i;
break;
}
}
return 0;
} | #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
int main() {
long long N, P;
cin >> N >> P;
long long temp;
bool flg;
for (long long i = pow(P, 1 / double(N)) + 1; i > 0; i--) {
temp = P;
flg = true;
if (i == 1) {
cout << i;
break;
}
for (long long j = 0; j < N; j++) {
if (temp % i == 0) {
temp = temp / i;
} else {
flg = false;
break;
}
}
if (flg) {
cout << i;
break;
}
}
return 0;
} | insert | 17 | 17 | 17 | 21 | TLE | |
p03194 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
int N, P;
cin >> N >> P;
int ans = 1;
for (int i = 1; pow(i, N) <= P; i++) {
int j = pow(i, N);
if (P % j == 0)
ans = i;
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
#define int long long
using namespace std;
signed main() {
int N, P;
cin >> N >> P;
int ans = 1;
if (N == 1) {
cout << P << endl;
return 0;
}
for (int i = 1; pow(i, N) <= P; i++) {
int j = pow(i, N);
if (P % j == 0)
ans = i;
}
cout << ans << endl;
}
| insert | 8 | 8 | 8 | 12 | TLE | |
p03194 | C++ | Time Limit Exceeded | #include <math.h>
#include <stdio.h>
#include <stdlib.h>
int main(void) {
long long int n, p;
long long int cur[60000] = {};
int count[60000] = {};
int check[60000] = {};
int end_flag = 0;
int index = 0;
int i, j;
long long int result;
scanf("%lld %lld", &n, &p);
if (n == 1) {
result = p;
} else {
// 素因数分解を順番にしていって、
// N個以上ある素因数の積を返す。
// 2の素因数分解
cur[index] = 2;
while (p % cur[index] == 0 && p > 1) {
count[index]++;
p /= cur[index];
}
// N個以上あったらフラグを立てる
if (count[index] >= n) {
check[index] = count[index] / n;
}
// 次の因数セット
index++;
cur[index] = 3;
while (p > 1 && p >= cur[index] * 2) {
// cur[index]の素因数分解
while (p % cur[index] == 0 && p > 1) {
count[index]++;
p /= cur[index];
// printf("p=%lld(%lld)\n",p,cur[index]);
}
// N個以上あったらフラグを立てる
if (count[index] >= n) {
check[index] = count[index] / n;
}
index++;
cur[index] = cur[index - 1] + 2;
do {
end_flag = 1;
for (i = 0; i < index; i++) {
if (cur[index] % cur[i] == 0) {
end_flag = 0;
cur[index] += 2;
break;
}
}
} while (end_flag == 0);
}
result = 1;
for (i = 0; i < index; i++) {
// printf("%d: cur=%lld, count=%d,
//check=%d\n",i,cur[i],count[i],check[i]);
result *= int(pow(double(cur[i]), check[i]));
// if(check[i] > 0){
// for(j = 0 ;j<check[i];j++){
// result *= pow(cur[i]);
// }
// printf("%d: cur=%ld, count=%ld,
//check=%d\n",i,cur[i],count[i],check[i]);
// }
}
}
printf("%lld\n", result);
return 0;
} | #include <math.h>
#include <stdio.h>
#include <stdlib.h>
int main(void) {
long long int n, p;
long long int cur[60000] = {};
int count[60000] = {};
int check[60000] = {};
int end_flag = 0;
int index = 0;
int i, j;
long long int result;
scanf("%lld %lld", &n, &p);
if (n == 1) {
result = p;
} else {
// 素因数分解を順番にしていって、
// N個以上ある素因数の積を返す。
// 2の素因数分解
cur[index] = 2;
while (p % cur[index] == 0 && p > 1) {
count[index]++;
p /= cur[index];
}
// N個以上あったらフラグを立てる
if (count[index] >= n) {
check[index] = count[index] / n;
}
// 次の因数セット
index++;
cur[index] = 3;
while (p > 1 && p >= cur[index] * cur[index]) {
// cur[index]の素因数分解
while (p % cur[index] == 0 && p > 1) {
count[index]++;
p /= cur[index];
// printf("p=%lld(%lld)\n",p,cur[index]);
}
// N個以上あったらフラグを立てる
if (count[index] >= n) {
check[index] = count[index] / n;
}
index++;
cur[index] = cur[index - 1] + 2;
do {
end_flag = 1;
for (i = 0; i < index; i++) {
if (cur[index] % cur[i] == 0) {
end_flag = 0;
cur[index] += 2;
break;
}
}
} while (end_flag == 0);
}
result = 1;
for (i = 0; i < index; i++) {
// printf("%d: cur=%lld, count=%d,
//check=%d\n",i,cur[i],count[i],check[i]);
result *= int(pow(double(cur[i]), check[i]));
// if(check[i] > 0){
// for(j = 0 ;j<check[i];j++){
// result *= pow(cur[i]);
// }
// printf("%d: cur=%ld, count=%ld,
//check=%d\n",i,cur[i],count[i],check[i]);
// }
}
}
printf("%lld\n", result);
return 0;
} | replace | 40 | 41 | 40 | 41 | TLE | |
p03194 | C++ | Time Limit Exceeded | #include <iostream>
#define ll long long
using namespace std;
typedef unsigned long long ull;
int main(void) {
// Your code here!
ll n, p;
cin >> n >> p;
ll ans = 1;
for (ll i = 2; i <= p; i++) {
ll count = 0;
while (p % i == 0) {
count++;
if (count == n) {
count = 0;
ans *= i;
}
p /= i;
}
}
cout << ans;
} | #include <iostream>
#define ll long long
using namespace std;
typedef unsigned long long ull;
int main(void) {
// Your code here!
ll n, p;
cin >> n >> p;
ll ans = 1;
for (ll i = 2; i * i <= p; i++) {
if (n == 1) {
ans = p;
break;
}
ll count = 0;
while (p % i == 0) {
count++;
if (count == n) {
count = 0;
ans *= i;
}
p /= i;
}
}
cout << ans;
}
| replace | 9 | 10 | 9 | 14 | TLE | |
p03194 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#define ll long long
#define fort(i, n) for (int i = 1; i <= n; ++i)
#define pi pair<int, int>
#define vi vector<int>
#define pb push_back
#define sz size()
#define er erase
#define fr first
#define sc second
#define rc(x) return cout << x, 0
using namespace std;
ll n, p, d;
ll power(ll a, ll b) {
if (b == 0ll)
return 1ll;
if (b % 2ll == 0ll)
return power(a, b / 2) * power(a, b / 2);
else
return a * power(a, b / 2) * power(a, b / 2);
}
int32_t main() {
ios_base ::sync_with_stdio(0);
cin.tie();
cout.tie();
cin >> n >> p;
if (n == 1)
rc(p);
for (ll i = 1ll; i <= p; ++i) {
if (power(i, n) <= p) {
if (p % power(i, n) == 0)
d = i;
} else
break;
}
cout << d;
}
| #include <bits/stdc++.h>
#define ll long long
#define fort(i, n) for (int i = 1; i <= n; ++i)
#define pi pair<int, int>
#define vi vector<int>
#define pb push_back
#define sz size()
#define er erase
#define fr first
#define sc second
#define rc(x) return cout << x, 0
using namespace std;
ll n, p, d;
ll power(ll a, ll b) {
if (b == 0ll)
return 1ll;
if (b % 2ll == 0ll)
return power(a, b / 2) * power(a, b / 2);
else
return a * power(a, b / 2) * power(a, b / 2);
}
int32_t main() {
ios_base ::sync_with_stdio(0);
cin.tie();
cout.tie();
cin >> n >> p;
if (n == 1)
rc(p);
if (n > log2(p))
rc(1);
for (ll i = 1ll; i <= p; ++i) {
if (power(i, n) <= p) {
if (p % power(i, n) == 0)
d = i;
} else
break;
}
cout << d;
}
| insert | 31 | 31 | 31 | 33 | TLE | |
p03194 | C++ | Time Limit Exceeded | #include <iostream>
#include <math.h>
using namespace std;
int main() {
long long int n, p, ans;
cin >> n >> p;
ans = pow((long double)p, 1.0 / (long double)n) + 1;
while (ans > 1) {
long long int num = 1;
long long int x = n;
while (x > 0) {
num *= ans;
x--;
}
if (p % num == 0) {
break;
} else {
ans--;
}
}
cout << ans << endl;
} | #include <iostream>
#include <math.h>
using namespace std;
int main() {
long long int n, p, ans;
cin >> n >> p;
ans = pow((long double)p, 1.0 / (long double)n) + 1;
while (ans > 1) {
if (p % (long long int)pow((long long int)ans, (long long int)n) == 0) {
break;
} else {
ans--;
}
}
cout << ans << endl;
} | replace | 10 | 17 | 10 | 11 | TLE | |
p03194 | C++ | Time Limit Exceeded | #include <cmath>
#include <cstdio>
int main() {
long long int n, k, p = 1, ans = 1;
scanf("%lld %lld", &k, &n);
while (n > 1) {
p++;
if (n % p != 0) {
continue;
}
long long int c = 0;
while (n % p == 0) {
n /= p;
c++;
}
ans *= pow(p, c / k);
}
printf("%lld\n", ans);
} | #include <cmath>
#include <cstdio>
int main() {
long long int n, k, p = 1, ans = 1;
scanf("%lld %lld", &k, &n);
if (k == 1) {
printf("%lld\n", n);
return 0;
}
while (n > 1 && p <= sqrt(n)) {
p++;
if (n % p != 0) {
continue;
}
long long int c = 0;
while (n % p == 0) {
n /= p;
c++;
}
ans *= pow(p, c / k);
}
printf("%lld\n", ans);
} | replace | 5 | 6 | 5 | 10 | TLE | |
p03194 | C++ | Runtime Error | /*
##############################
# Author: Pratyush Gaurav #
# College: NIT ROURKELA #
##############################
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef long double ld;
typedef pair<lli, lli> plli;
typedef vector<lli> vlli;
typedef vector<plli> vplli;
#define IOS \
ios_base::sync_with_stdio(false); \
cin.tie(NULL);
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x) * (x)
#define all(a) a.begin(), a.end()
#define UN(v) sort(all(v)), v.resize(unique(all(v)) - v.begin())
#define endl '\n'
const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;
lli dx[] = {0, 0, -1, 1, -1, -1, 1, 1};
lli dy[] = {1, -1, 0, 0, 1, -1, -1, 1};
lli ans = 1;
lli n, p;
lli power(lli a, lli b) {
if (b == 0) {
return 1;
}
lli temp = power(a, b / 2);
if (temp * temp > p) {
cout << ans << endl;
exit(0);
}
if (temp * temp > 1e6 and a > 1e6) {
cout << ans << endl;
exit(0);
}
lli res = (b & 1 ? temp * a * temp : temp * temp);
return res;
}
void solve() {
cin >> n >> p;
if (n == 1) {
cout << p << endl;
return;
} else {
lli x = 1;
while (1) {
lli val = power(x, n);
if (val > p)
break;
if (p % val == 0) {
ans = max(ans, x);
}
x++;
}
}
// cout << (1e18) << endl;
cout << ans << endl;
}
int main() {
IOS;
lli t = 1;
// cin >> t;
while (t--)
solve();
return 0;
}
| /*
##############################
# Author: Pratyush Gaurav #
# College: NIT ROURKELA #
##############################
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long lli;
typedef long double ld;
typedef pair<lli, lli> plli;
typedef vector<lli> vlli;
typedef vector<plli> vplli;
#define IOS \
ios_base::sync_with_stdio(false); \
cin.tie(NULL);
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) ((a * b) / gcd(a, b))
#define sqr(x) (x) * (x)
#define all(a) a.begin(), a.end()
#define UN(v) sort(all(v)), v.resize(unique(all(v)) - v.begin())
#define endl '\n'
const long long INF = 100000000000000000;
const long long MOD = 1000000007;
const long long MAXN = 100005;
lli dx[] = {0, 0, -1, 1, -1, -1, 1, 1};
lli dy[] = {1, -1, 0, 0, 1, -1, -1, 1};
lli ans = 1;
lli n, p;
lli power(lli a, lli b) {
if (b == 0) {
return 1;
}
lli temp = power(a, b / 2);
if (temp > 1e6) {
cout << ans << endl;
exit(0);
}
if (temp * temp > p) {
cout << ans << endl;
exit(0);
}
if (temp * temp > 1e6 and a > 1e6) {
cout << ans << endl;
exit(0);
}
lli res = (b & 1 ? temp * a * temp : temp * temp);
return res;
}
void solve() {
cin >> n >> p;
if (n == 1) {
cout << p << endl;
return;
} else {
lli x = 1;
while (1) {
lli val = power(x, n);
if (val > p)
break;
if (p % val == 0) {
ans = max(ans, x);
}
x++;
}
}
// cout << (1e18) << endl;
cout << ans << endl;
}
int main() {
IOS;
lli t = 1;
// cin >> t;
while (t--)
solve();
return 0;
}
| insert | 43 | 43 | 43 | 47 | 0 | |
p03194 | C++ | Time Limit Exceeded | #include <algorithm>
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
#define M 1000000007
ll power(ll a, ll n) {
ll ans = 1;
while (0 < n) {
if (n % 2 == 0) {
a *= a;
n >>= 1;
} else {
ans *= a;
n--;
}
}
return ans;
}
int main(void) {
ll n, p, ans = 1;
cin >> n >> p;
if (n >= 40) {
cout << 1 << endl;
return 0;
}
for (int i = 2; power(i, n) <= p; i++) {
while (p % power(i, n) == 0) {
ans *= i;
p /= power(i, n);
}
}
cout << ans << endl;
return 0;
}
| #include <algorithm>
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
#define M 1000000007
ll power(ll a, ll n) {
ll ans = 1;
while (0 < n) {
if (n % 2 == 0) {
a *= a;
n >>= 1;
} else {
ans *= a;
n--;
}
}
return ans;
}
int main(void) {
ll n, p, ans = 1;
cin >> n >> p;
if (n == 1) {
cout << p << endl;
return 0;
}
if (n >= 40) {
cout << 1 << endl;
return 0;
}
for (int i = 2; power(i, n) <= p; i++) {
while (p % power(i, n) == 0) {
ans *= i;
p /= power(i, n);
}
}
cout << ans << endl;
return 0;
}
| replace | 24 | 25 | 24 | 28 | TLE | |
p03194 | Python | Time Limit Exceeded | N, P = list(map(int, input().split()))
if N == 1:
print(P)
exit()
elif P == 1:
print("1")
exit()
ans = 1
tmp = P
for i in range(2, P):
po = pow(i, N)
while tmp % po == 0:
tmp = tmp // po
ans = ans * i
# print(i, tmp, ans)
if tmp < po:
break
print(ans)
| N, P = list(map(int, input().split()))
if N == 1:
print(P)
exit()
elif P == 1:
print("1")
exit()
ans = 1
tmp = P
for i in range(2, int(pow(P, 1 / N)) + 1):
po = pow(i, N)
while tmp % po == 0:
tmp = tmp // po
ans = ans * i
# print(i, tmp, ans)
if tmp < po:
break
print(ans)
| replace | 11 | 12 | 11 | 12 | TLE | |
p03194 | Python | Time Limit Exceeded | from collections import Counter
def d(P):
c = Counter()
i = 2
while P > 1:
if P % i == 0:
c.update([i])
P //= i
i -= 1
i += 1
return c
def solve(N, P):
c = d(P)
ans = 1
for k in [k for k, v in c.items() if v >= N]:
ans *= k ** (c[k] // N)
return ans
if __name__ == "__main__":
N, X = tuple(map(int, input().split(" ")))
print(solve(N, X))
| from collections import Counter
def d(P):
c = Counter()
i = 2
while P > 1:
if P % i == 0:
c.update([i])
P //= i
i -= 1
i += 1
if i > P**0.5:
c.update([P])
break
return c
def solve(N, P):
c = d(P)
ans = 1
for k in [k for k, v in c.items() if v >= N]:
ans *= k ** (c[k] // N)
return ans
if __name__ == "__main__":
N, X = tuple(map(int, input().split(" ")))
print(solve(N, X))
| insert | 12 | 12 | 12 | 15 | TLE | |
p03194 | Python | Time Limit Exceeded | n, p = map(int, input().split())
if n == 1:
print(p)
else:
m = 1
while m**n <= p:
m += 1
for i in reversed(range(1, m + 1)):
if p % (i**n) == 0:
print(i)
break
| n, p = map(int, input().split())
if n == 1:
print(p)
else:
m = int((p + 1) ** (1 / n))
while m**n > p:
m -= 1
for i in reversed(range(1, m + 1)):
if p % (i**n) == 0:
print(i)
break
| replace | 5 | 8 | 5 | 8 | TLE | |
p03194 | Python | Time Limit Exceeded | import math
N, P = list(map(int, input().split()))
for i in range(int(math.pow(P, 1 / N)) + 1, 0, -1):
if P % (i**N) == 0:
print(i)
break
| n, p = map(int, input().split())
if n == 1:
print(p)
else:
for i in range(1, round(p ** (1 / n)) + 1):
if p % i**n == 0:
res = i
print(res)
| replace | 0 | 8 | 0 | 8 | TLE | |
p03194 | C++ | Time Limit Exceeded | #include <cmath>
#include <iostream>
#include <stdio.h>
#include <utility>
#include <vector>
using namespace std;
int main() {
unsigned long n, p;
cin >> n >> p;
vector<pair<unsigned long, unsigned long>> factors;
// prime factorize p
for (unsigned long i = 2; i <= p; i++) {
unsigned long j = 0;
for (j = 0; p % i == 0; j++) {
p = p / i;
}
if (j > 0) {
factors.push_back({i, j});
}
}
unsigned long max_factor = 1;
for (pair<unsigned long, unsigned long> factor_pair : factors) {
unsigned long factor = get<0>(factor_pair);
unsigned long exp = get<1>(factor_pair);
unsigned long mult = static_cast<unsigned long>(exp / n);
unsigned long mult_factor = powl(factor, mult);
if (exp >= n) {
max_factor *= mult_factor;
}
// printf("%lu %lu => %lu ^ %lu = %lu\n", factor, exp,
// factor, mult, mult_factor);
}
printf("%lu\n", max_factor);
return 0;
}
| #include <cmath>
#include <iostream>
#include <stdio.h>
#include <utility>
#include <vector>
using namespace std;
int main() {
unsigned long n, p;
cin >> n >> p;
vector<pair<unsigned long, unsigned long>> factors;
// prime factorize p
for (unsigned long i = 2; i <= p; i++) {
unsigned long j = 0;
if (i > sqrt(p)) {
if (i < p) {
factors.push_back({p, 1});
}
break;
}
for (j = 0; p % i == 0; j++) {
p = p / i;
}
if (j > 0) {
factors.push_back({i, j});
}
}
unsigned long max_factor = 1;
for (pair<unsigned long, unsigned long> factor_pair : factors) {
unsigned long factor = get<0>(factor_pair);
unsigned long exp = get<1>(factor_pair);
unsigned long mult = static_cast<unsigned long>(exp / n);
unsigned long mult_factor = powl(factor, mult);
if (exp >= n) {
max_factor *= mult_factor;
}
// printf("%lu %lu => %lu ^ %lu = %lu\n", factor, exp,
// factor, mult, mult_factor);
}
printf("%lu\n", max_factor);
return 0;
}
| insert | 13 | 13 | 13 | 19 | TLE | |
p03194 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
#define ll long long
ll f(ll x, ll res) {
ll ans = 1;
while (x) {
if (x & 1)
ans = ans * res;
res *= res;
x /= 2;
}
return ans;
}
int main() {
ll n, p;
ll ans = 1;
cin >> n >> p;
for (ll i = 2;; i++) {
ll k = f(n, i);
if (p < k)
break;
if (p % k == 0)
ans = i;
}
printf("%lld\n", ans);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define ll long long
ll f(ll x, ll res) {
ll ans = 1;
while (x) {
if (x & 1)
ans = ans * res;
res *= res;
x /= 2;
}
return ans;
}
int main() {
ll n, p;
ll ans = 1;
cin >> n >> p;
if (n == 1) {
cout << p;
return 0;
}
if (p == 1) {
cout << "1";
return 0;
}
if (n >= p) {
cout << "1";
return 0;
}
if (n > 1000000) {
cout << "1";
return 0;
}
for (ll i = 2;; i++) {
ll k = f(n, i);
if (p < k)
break;
if (p % k == 0)
ans = i;
}
printf("%lld\n", ans);
return 0;
}
| insert | 17 | 17 | 17 | 33 | 0 | |
p03194 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e6 + 7;
const int Inf = 1 << 30;
const ll INF = 1LL << 60;
#define mst(x) memset(x, 0, sizeof(x))
ll n, p;
ll pr[maxx]; // p的所有因子
map<ll, bool> vis;
ll ans;
int main() {
vis.clear();
cin >> n >> p;
if (n == 1) {
cout << p << endl;
return 0;
}
int tot = 0;
for (int i = 1; i <= sqrt(p); i++) {
if (p % i == 0)
pr[++tot] = i;
}
int dd;
double tmp = sqrt(p);
if (tmp == (int)tmp)
dd = tot - 1;
else
dd = tot;
for (int i = 1; i <= dd; i++)
pr[++tot] = p / pr[i];
sort(pr + 1, pr + tot + 1);
// 如果除1以外的最小因子的n次幂都比p大, 那gcd必为1
ll f = pr[2]; // 除1以外的最小因子
ll m = 1;
while (f * pr[2] <= p) {
f *= pr[2];
m++;
}
if (m < n) {
puts("1");
return 0;
}
for (int i = 1; i <= tot; i++)
vis[pr[i]] = 1;
bool chk = 0;
for (int i = tot; i >= 2; i--) {
ll pp = pr[i];
ll cnt = 1;
bool flg = 0;
while (pp * pr[i] <= p) {
pp *= pr[i];
cnt++;
if (cnt == n) {
flg = 1;
break;
}
}
if (flg && vis[pp]) {
chk = 1;
ans = pr[i];
break;
}
}
if (!chk)
puts("1");
else
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxx = 1e6 + 7;
const int Inf = 1 << 30;
const ll INF = 1LL << 60;
#define mst(x) memset(x, 0, sizeof(x))
ll n, p;
ll pr[maxx]; // p的所有因子
map<ll, bool> vis;
ll ans;
int main() {
vis.clear();
cin >> n >> p;
if (n == 1) {
cout << p << endl;
return 0;
}
int tot = 0;
for (int i = 1; i <= sqrt(p); i++) {
if (p % i == 0)
pr[++tot] = i;
}
int dd;
double tmp = sqrt(p);
if (tmp == (int)tmp)
dd = tot - 1;
else
dd = tot;
for (int i = 1; i <= dd; i++)
pr[++tot] = p / pr[i];
sort(pr + 1, pr + tot + 1);
/* 如果除1以外的最小因子的n次幂都比p大, 那gcd必为1 */
if (tot > 1) {
ll f = pr[2]; // 除1以外的最小因子
ll m = 1;
while (f * pr[2] <= p) {
f *= pr[2];
m++;
}
if (m < n) {
puts("1");
return 0;
}
}
for (int i = 1; i <= tot; i++)
vis[pr[i]] = 1;
bool chk = 0;
for (int i = tot; i >= 2; i--) {
ll pp = pr[i];
ll cnt = 1;
bool flg = 0;
while (pp * pr[i] <= p) {
pp *= pr[i];
cnt++;
if (cnt == n) {
flg = 1;
break;
}
}
if (flg && vis[pp]) {
chk = 1;
ans = pr[i];
break;
}
}
if (!chk)
puts("1");
else
cout << ans << endl;
} | replace | 34 | 44 | 34 | 46 | TLE | |
p03194 | C++ | Time Limit Exceeded | #include <iostream>
#include <math.h>
using namespace std;
int main(void) {
long ans = 0;
long long n = 0, i, N, P;
cin >> N >> P;
for (i = 1; n < P && n >= 0; i++) {
n = powl(i, N);
// cout<<n<<" "<<i<<" "<<P<<" "<<ans<<endl;
if (P % n == 0)
ans = i;
}
cout << ans << endl;
return 0;
} | #include <iostream>
#include <math.h>
using namespace std;
int main(void) {
long ans = 0;
long long n = 0, i, N, P;
cin >> N >> P;
if (N == 1) {
cout << P << endl;
return 0;
}
for (i = 1; n < P && n >= 0; i++) {
n = powl(i, N);
// cout<<n<<" "<<i<<" "<<P<<" "<<ans<<endl;
if (P % n == 0)
ans = i;
}
cout << ans << endl;
return 0;
}
| insert | 7 | 7 | 7 | 11 | TLE | |
p03194 | C++ | Time Limit Exceeded | #define ioFix \
ios::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
long long madd(long long x, long long y, long long modulo) {
return (x + y) % modulo;
}
long long mmult(long long x, long long y, long long modulo) {
return (x * y) % modulo;
}
long long mpow(long long base, long long exponent, long long modulo) {
long long res = 1;
for (int i = 0; i < exponent; i++)
res = (res * base) % modulo;
return res;
}
long long mfac(long long n, long long modulo) {
long long res = 1;
for (int i = 2; i <= n; i++)
res = (res * i) % modulo;
return res;
}
long long mcomb(long long n, long long k, long long modulo) {
return mfac(n, modulo) / mmult(mfac(k, modulo), mfac(n - k, modulo), modulo);
}
#define PI (2.0 * acos(0.0))
#define INF (int)1e9
#define LINF (long long)1e18
#define EPS 1e-9
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pdd pair<double, double>
#define pcc pair<char, char>
#define pbb pair<bool, bool>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vvs vector<vector<string>>
#define REP(n) for (int xix = 0; xix < (n); xix++)
#define FOR(i, from, to) for (int(i) = from; (i) < (to); (i)++)
#define RANGE(i, from, to) for (int(i) = from; (i) <= (to); (i)++)
#define ALL(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fillArray(arr, val) std::fill(std::begin(arr), std::end(arr), (val))
#define pow2(x) ((x) * (x))
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define watch(x) cout << (#x) << " is " << (x) << endl
#define watchVector(v) \
{ \
for (int xvx = 0; xvx < (v).size(); xvx++) { \
cout << (v)[xvx] << " "; \
} \
cout << endl; \
}
#define watchArray(arr, n) \
{ \
for (int xax = 0; xax < (n); xax++) { \
cout << (arr)[xax] << " "; \
} \
cout << endl; \
}
#define watchMatrix(x, rows, cols) \
for (int r = 0; r < (rows); r++) { \
for (int c = 0; c < (cols); c++) { \
cout << (x)[r][c] << " "; \
} \
cout << endl; \
}
#include <bits/stdc++.h>
using namespace std;
ll gcd(ll a, ll b) {
if (a == 0)
return b;
return gcd(b % a, a);
}
int main() {
ioFix;
ll N, P;
cin >> N >> P;
priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>>
pq; // <val, index>
FOR(i, 0, N)
pq.push(mp(1, i));
ll divCounter = 0;
ll div = 2;
ll big = P;
ll sqrtP = ceil(sqrt(P));
while (big > 1) {
auto p = pq.top();
while (big % div != 0 && div <= sqrtP) {
div++;
}
if (div > sqrtP)
div = big;
big /= div;
p.first *= div;
divCounter++;
pq.pop();
pq.push(p);
}
if (divCounter < N) {
cout << 1 << endl;
return 0;
}
ll res = pq.top().first;
while (!pq.empty()) {
res = gcd(res, pq.top().first);
pq.pop();
}
cout << res << endl;
}
| #define ioFix \
ios::sync_with_stdio(false); \
cin.tie(0); \
cout.tie(0);
long long madd(long long x, long long y, long long modulo) {
return (x + y) % modulo;
}
long long mmult(long long x, long long y, long long modulo) {
return (x * y) % modulo;
}
long long mpow(long long base, long long exponent, long long modulo) {
long long res = 1;
for (int i = 0; i < exponent; i++)
res = (res * base) % modulo;
return res;
}
long long mfac(long long n, long long modulo) {
long long res = 1;
for (int i = 2; i <= n; i++)
res = (res * i) % modulo;
return res;
}
long long mcomb(long long n, long long k, long long modulo) {
return mfac(n, modulo) / mmult(mfac(k, modulo), mfac(n - k, modulo), modulo);
}
#define PI (2.0 * acos(0.0))
#define INF (int)1e9
#define LINF (long long)1e18
#define EPS 1e-9
#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<long long, long long>
#define pdd pair<double, double>
#define pcc pair<char, char>
#define pbb pair<bool, bool>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vs vector<string>
#define vvs vector<vector<string>>
#define REP(n) for (int xix = 0; xix < (n); xix++)
#define FOR(i, from, to) for (int(i) = from; (i) < (to); (i)++)
#define RANGE(i, from, to) for (int(i) = from; (i) <= (to); (i)++)
#define ALL(x) x.begin(), x.end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fillArray(arr, val) std::fill(std::begin(arr), std::end(arr), (val))
#define pow2(x) ((x) * (x))
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
#define watch(x) cout << (#x) << " is " << (x) << endl
#define watchVector(v) \
{ \
for (int xvx = 0; xvx < (v).size(); xvx++) { \
cout << (v)[xvx] << " "; \
} \
cout << endl; \
}
#define watchArray(arr, n) \
{ \
for (int xax = 0; xax < (n); xax++) { \
cout << (arr)[xax] << " "; \
} \
cout << endl; \
}
#define watchMatrix(x, rows, cols) \
for (int r = 0; r < (rows); r++) { \
for (int c = 0; c < (cols); c++) { \
cout << (x)[r][c] << " "; \
} \
cout << endl; \
}
#include <bits/stdc++.h>
using namespace std;
ll gcd(ll a, ll b) {
if (a == 0)
return b;
return gcd(b % a, a);
}
int main() {
ioFix;
ll N, P;
cin >> N >> P;
if (N > log2(P)) {
cout << 1 << endl;
return 0;
}
priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>>
pq; // <val, index>
FOR(i, 0, N)
pq.push(mp(1, i));
ll divCounter = 0;
ll div = 2;
ll big = P;
ll sqrtP = ceil(sqrt(P));
while (big > 1) {
auto p = pq.top();
while (big % div != 0 && div <= sqrtP) {
div++;
}
if (div > sqrtP)
div = big;
big /= div;
p.first *= div;
divCounter++;
pq.pop();
pq.push(p);
}
if (divCounter < N) {
cout << 1 << endl;
return 0;
}
ll res = pq.top().first;
while (!pq.empty()) {
res = gcd(res, pq.top().first);
pq.pop();
}
cout << res << endl;
}
| insert | 108 | 108 | 108 | 114 | TLE | |
p03194 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <unordered_set>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)
unordered_multiset<long long int> fact(long long int n) {
unordered_multiset<long long int> ret;
long long int a = 2;
while (n != 1) {
if (n % a == 0) {
n /= a;
ret.insert(a--);
}
a++;
}
return ret;
}
int main() {
long long int n, p;
cin >> n >> p;
if (n == 1) {
cout << p;
return 0;
}
if (n >= 40) {
cout << "1" << endl;
return 0;
}
long long int ans = 1;
auto l = fact(p);
long long int cnt = 0;
for (long long int i = 1; p >= pow(i - 1, n); ++i)
cnt = i;
rep(i, cnt) {
long long int tmp = l.count(i);
if (tmp >= n)
ans *= pow(i, tmp / n);
}
cout << ans << endl;
} | #include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <unordered_set>
#include <vector>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; ++i)
unordered_multiset<long long int> fact(long long int n) {
unordered_multiset<long long int> ret;
long long int a = 2;
while (n != 1) {
if (n % a == 0) {
n /= a;
ret.insert(a--);
}
a++;
}
return ret;
}
int main() {
long long int n, p;
cin >> n >> p;
if (n == 1) {
cout << p;
return 0;
}
if (n >= 40 || n == 16) {
cout << "1" << endl;
return 0;
}
long long int ans = 1;
auto l = fact(p);
long long int cnt = 0;
for (long long int i = 1; p >= pow(i - 1, n); ++i)
cnt = i;
rep(i, cnt) {
long long int tmp = l.count(i);
if (tmp >= n)
ans *= pow(i, tmp / n);
}
cout << ans << endl;
}
| replace | 27 | 28 | 27 | 28 | TLE | |
p03194 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#define dum(x) cout << #x << '=' << x << endl
#define ll long long
using namespace std;
int main() {
ll n, p;
cin >> n >> p;
ll ans = 1;
for (int i = 2; i * i <= p; i++) {
int cnt = 0;
while (p % i == 0) {
cnt++;
p /= i;
}
int tmp = cnt / n;
for (int j = 0; j < tmp; j++) {
ans *= i;
}
}
if (n == 1)
ans *= p;
cout << ans << endl;
}
| #include <bits/stdc++.h>
#define dum(x) cout << #x << '=' << x << endl
#define ll long long
using namespace std;
int main() {
ll n, p;
cin >> n >> p;
ll ans = 1;
for (ll i = 2; i * i <= p; i++) {
int cnt = 0;
while (p % i == 0) {
cnt++;
p /= i;
}
int tmp = cnt / n;
for (int j = 0; j < tmp; j++) {
ans *= i;
}
}
if (n == 1)
ans *= p;
cout << ans << endl;
}
| replace | 10 | 11 | 10 | 11 | TLE | |
p03194 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cmath>
#include <iostream>
#include <math.h>
#include <set>
#include <string>
using namespace std;
int main(void) {
ios::sync_with_stdio(false);
long N, P, i, k, j, a, s;
cin >> N >> P;
s = (long)pow((double)(P), 1.0 / (double)(N));
a = 0;
for (i = 1; i <= s + 1; i++) {
j = (long)pow((double)(i), (double)(N));
if (P % j == 0)
a = i;
if (P <= j)
break;
}
cout << a;
return 0;
}
| #include <algorithm>
#include <cmath>
#include <iostream>
#include <math.h>
#include <set>
#include <string>
using namespace std;
int main(void) {
ios::sync_with_stdio(false);
long N, P, i, k, j, a, s;
cin >> N >> P;
s = (long)pow((double)(P), 1.0 / (double)(N));
a = 0;
if (N == 1)
a = P;
else {
for (i = 1; i <= s + 1; i++) {
j = (long)pow((double)(i), (double)(N));
if (P % j == 0)
a = i;
if (P <= j)
break;
}
}
cout << a;
return 0;
}
| replace | 14 | 20 | 14 | 25 | TLE | |
p03194 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <regex>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
int main(int argc, char const *argv[]) {
ll n, p;
cin >> n >> p;
ll radicand = 1;
ll ans = 1;
while (pow(radicand, n) <= p) {
if (p % (ll)pow(radicand, n) == 0)
ans = radicand;
radicand++;
}
cout << ans << endl;
return 0;
}
| #include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <queue>
#include <regex>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
int main(int argc, char const *argv[]) {
ll n, p;
cin >> n >> p;
ll radicand = 1;
ll ans = 1;
if (n == 1) {
cout << p << endl;
return 0;
}
while (pow(radicand, n) <= p) {
if (p % (ll)pow(radicand, n) == 0)
ans = radicand;
radicand++;
}
cout << ans << endl;
return 0;
}
| insert | 23 | 23 | 23 | 27 | TLE | |
p03194 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, num, verysum = 1;
cin >> n >> num;
if (n >= 40) {
cout << 1;
return 0;
}
for (int i = 2; i <= num; i++) {
long long t = num;
while (t % int(pow(i, n)) == 0)
verysum *= i, t /= (pow(i, n));
num = t;
}
cout << verysum;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, num, verysum = 1;
cin >> n >> num;
if (n >= 40) {
cout << 1;
return 0;
}
if (n == 1) {
cout << num;
return 0;
}
for (int i = 2; pow(i, n) <= num; i++) {
while (num % (long long)(pow(i, n)) == 0)
verysum *= i, num /= (pow(i, n));
}
cout << verysum;
} | replace | 9 | 14 | 9 | 16 | TLE | |
p03194 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
int main() {
long N, P;
cin >> N;
cin >> P;
long zantei = 1;
long temp;
if (N == 1) {
zantei = P;
} else if (P == 1) {
} else {
for (long i = 2; i <= P; i++) {
temp = pow(i, N);
if (temp > P) {
break;
}
if (P % temp == 0) {
zantei = i;
}
}
}
cout << zantei << endl;
}
| #include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <string>
#include <vector>
using namespace std;
int main() {
long N, P;
cin >> N;
cin >> P;
long zantei = 1;
long temp;
if (N == 1) {
zantei = P;
} else if (P == 1 || N > 39) {
} else {
for (long i = 2; i <= P; i++) {
temp = pow(i, N);
if (temp > P) {
break;
}
if (P % temp == 0) {
zantei = i;
}
}
}
cout << zantei << endl;
}
| replace | 17 | 18 | 17 | 18 | TLE | |
p03194 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
ll N, P, ans = 1;
cin >> N >> P;
for (ll i = 2; pow(i, N) <= P; i++) {
ll tmp = pow(i, N);
if (P % tmp == 0)
ans = i;
}
printf("%lld\n", ans);
}
| #include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
ll N, P, ans = 1;
cin >> N >> P;
if (N == 1) {
printf("%lld\n", P);
return 0;
}
for (ll i = 2; pow(i, N) <= P; i++) {
ll tmp = pow(i, N);
if (P % tmp == 0)
ans = i;
}
printf("%lld\n", ans);
}
| insert | 6 | 6 | 6 | 10 | TLE | |
p03194 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a, n) vector<int>(a)((n))
#define Vec(a, n) vector<string>(a)((n))
#define P pair<int, int>
#define PQ(n) priority_queue<P, vector<P>, greater<P>>(n)
#define pq(n) priority_queue<int>(n)
using namespace std;
signed main() {
int n, p, ans = 1;
cin >> n >> p;
if (n == 1) {
cout << p << endl;
return 0;
}
int temp = p;
for (int i = 2; p >= i * i; i++) {
int tmp = temp;
int x = 1, cnt = 0;
while (x == 1) {
if (tmp % i != 0) {
x = 0;
} else {
cnt++;
tmp /= i;
}
}
REP(j, cnt / n) {
ans *= i;
REP(k, cnt / n) { temp /= i; }
}
}
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a, n) vector<int>(a)((n))
#define Vec(a, n) vector<string>(a)((n))
#define P pair<int, int>
#define PQ(n) priority_queue<P, vector<P>, greater<P>>(n)
#define pq(n) priority_queue<int>(n)
using namespace std;
signed main() {
int n, p, ans = 1;
cin >> n >> p;
if (n == 1) {
cout << p << endl;
return 0;
}
int temp = p;
for (int i = 2; p >= i * i; i++) {
int tmp = temp;
int x = 1, cnt = 0;
while (x == 1) {
if (tmp % i != 0) {
x = 0;
} else {
cnt++;
tmp /= i;
}
}
int temp1 = 1;
REP(j, cnt / n) { temp1 *= i; }
if (temp1 != 1) {
ans *= temp1;
REP(k, n) { temp /= temp1; }
}
}
cout << ans << endl;
return 0;
}
| replace | 31 | 34 | 31 | 36 | TLE | |
p03194 | C++ | Time Limit Exceeded | #include <iostream>
#include <map>
using namespace std;
typedef long long int ll;
map<ll, ll> M;
ll N, P, ans = 1;
void disassemble(ll p) {
for (int i = 2; i * i <= p; i++) {
ll cnt = 0;
while (p % i == 0) {
cnt++;
p /= i;
if (cnt == N) {
ans *= i;
cnt = 0;
}
}
}
}
int main() {
cin >> N >> P;
disassemble(P);
if (N == 1) {
cout << P << endl;
} else {
cout << ans << endl;
}
return 0;
} | #include <iostream>
#include <map>
using namespace std;
typedef long long int ll;
map<ll, ll> M;
ll N, P, ans = 1;
void disassemble(ll p) {
for (ll i = 2; i * i <= p; i++) {
ll cnt = 0;
while (p % i == 0) {
cnt++;
p /= i;
if (cnt == N) {
ans *= i;
cnt = 0;
}
}
}
}
int main() {
cin >> N >> P;
disassemble(P);
if (N == 1) {
cout << P << endl;
} else {
cout << ans << endl;
}
return 0;
} | replace | 10 | 11 | 10 | 11 | TLE | |
p03194 | C++ | Time Limit Exceeded | #include <iostream>
#include <map>
using namespace std;
map<long, long> prime_factor(long long n) {
map<long, long> res;
for (int i = 2; i * i <= n; i++) {
while (n % i == 0) {
++res[i];
n /= i;
}
}
if (n != 1)
res[n] = 1;
return res;
}
long long mod_pow(long long x, long long n) {
long long res = 1;
while (n > 0) {
if (n & 1)
res = res * x;
x = x * x;
n >>= 1;
}
return res;
}
int main() {
long long N, P;
cin >> N >> P;
map<long, long> mp = prime_factor(P);
long long ans = 1;
for (auto it = mp.begin(); it != mp.end(); ++it) {
if (it->second >= N)
ans *= mod_pow(it->first, it->second / N);
}
cout << ans << endl;
}
| #include <iostream>
#include <map>
using namespace std;
map<long, long> prime_factor(long long n) {
map<long, long> res;
for (long long i = 2; i * i <= n; i++) {
while (n % i == 0) {
++res[i];
n /= i;
}
}
if (n != 1)
res[n] = 1;
return res;
}
long long mod_pow(long long x, long long n) {
long long res = 1;
while (n > 0) {
if (n & 1)
res = res * x;
x = x * x;
n >>= 1;
}
return res;
}
int main() {
long long N, P;
cin >> N >> P;
map<long, long> mp = prime_factor(P);
long long ans = 1;
for (auto it = mp.begin(); it != mp.end(); ++it) {
if (it->second >= N)
ans *= mod_pow(it->first, it->second / N);
}
cout << ans << endl;
}
| replace | 6 | 7 | 6 | 7 | TLE | |
p03194 | C++ | Time Limit Exceeded | #include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
#define ll long long int
int main(int argc, const char *argv[]) {
ll N, P;
cin >> N >> P;
if (N == 1) {
cout << P << endl;
return 0;
}
// int max = (int)sqrt(P)+1;
ll max = P / 2;
ll ret = 1;
for (ll divider = 2; divider <= max && P != 1; ++divider) {
ll count = 0;
while (P % divider == 0) {
// cerr << divider;
count++;
P /= divider;
}
if (count > 0) {
// cerr << divider << "**" << count << endl;
}
while (count >= N) {
// cerr << divider << endl;
ret *= divider;
count -= N;
}
}
cout << ret << endl;
}
| #include <cmath>
#include <cstdio>
#include <iostream>
using namespace std;
#define ll long long int
int main(int argc, const char *argv[]) {
ll N, P;
cin >> N >> P;
if (N == 1) {
cout << P << endl;
return 0;
}
ll max = (int)pow(1.0 * P, 1.0 / N);
ll ret = 1;
for (ll divider = 2; divider <= max && P != 1; ++divider) {
ll count = 0;
while (P % divider == 0) {
// cerr << divider;
count++;
P /= divider;
}
if (count > 0) {
// cerr << divider << "**" << count << endl;
}
while (count >= N) {
// cerr << divider << endl;
ret *= divider;
count -= N;
}
}
cout << ret << endl;
}
| replace | 13 | 15 | 13 | 14 | TLE | |
p03194 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main() {
string s;
long long ans = 1, n, a;
cin >> n >> a;
for (long long i = 2; i <= a; i++) {
if (a % i == 0) {
int cnt = 0;
while (a % i == 0) {
cnt++;
a /= i;
}
cnt /= n;
for (int j = 0; j < cnt; j++)
ans *= i;
}
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
string s;
long long ans = 1, n, a;
cin >> n >> a;
if (n == 1) {
cout << a << endl;
return 0;
}
for (long long i = 2; i <= sqrt(a) + 1; i++) {
if (a % i == 0) {
int cnt = 0;
while (a % i == 0) {
cnt++;
a /= i;
}
cnt /= n;
for (int j = 0; j < cnt; j++)
ans *= i;
}
}
cout << ans << endl;
return 0;
} | replace | 8 | 9 | 8 | 13 | TLE | |
p03194 | C++ | Time Limit Exceeded | #include <iostream>
#include <map>
using namespace std;
long long n, p, cnt;
map<long long, int> v;
int main() {
cin >> n >> p;
for (int i = 2; i * i <= p; i++)
while (p % i == 0)
v[i]++, p /= i, cnt++;
if (p > 1)
v[p]++;
long long res = 1;
for (map<long long, int>::iterator it = v.begin(); it != v.end(); it++)
for (int i = 0; i < (*it).second / n; i++)
res *= it->first;
cout << res;
}
| #include <iostream>
#include <map>
using namespace std;
long long n, p, cnt;
map<long long, int> v;
int main() {
cin >> n >> p;
for (int i = 2; i * 1ll * i <= p; i++)
while (p % i == 0)
v[i]++, p /= i, cnt++;
if (p > 1)
v[p]++;
long long res = 1;
for (map<long long, int>::iterator it = v.begin(); it != v.end(); it++)
for (int i = 0; i < (*it).second / n; i++)
res *= it->first;
cout << res;
}
| replace | 7 | 8 | 7 | 8 | TLE | |
p03194 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back
typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;
int main(void) {
cin.tie(0);
ios::sync_with_stdio(false);
ll n, p;
cin >> n >> p;
if (p == 1)
cout << 1 << endl;
else {
ll ans = 1;
for (ll i = 2; i <= p; i++) {
ll tmp = pow(i, n);
if (tmp <= p && p % tmp == 0) {
ans = max(ans, i);
}
}
cout << ans << endl;
}
return 0;
} | #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back
typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;
int main(void) {
cin.tie(0);
ios::sync_with_stdio(false);
ll n, p;
cin >> n >> p;
if (p == 1)
cout << 1 << endl;
else {
ll ans = 1, yj = sqrt(p);
if (n == 1)
ans = p;
else {
for (ll i = 2; i <= yj; i++) {
ll tmp = pow(i, n);
if (tmp <= p && p % tmp == 0) {
ans = max(ans, i);
}
}
}
cout << ans << endl;
}
return 0;
} | replace | 33 | 38 | 33 | 43 | TLE | |
p03194 | C++ | Time Limit Exceeded | #include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
int main() {
ll N, P;
cin >> N >> P;
ll tmp = 2;
ll cnt;
ll ans = 1;
if (N == 1) {
cout << P;
} else {
cnt = 0;
while (P % tmp == 0) {
P = P / tmp;
cnt++;
}
ans *= pow(tmp, cnt / N);
tmp = 3;
while (tmp < P) {
cnt = 0;
while (P % tmp == 0) {
P = P / tmp;
cnt++;
}
ans *= pow(tmp, cnt / N);
tmp += 2;
}
cout << ans;
}
return 0;
}
| #include <algorithm>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define ll long long
int main() {
ll N, P;
cin >> N >> P;
ll tmp = 2;
ll cnt;
ll ans = 1;
if (N == 1) {
cout << P;
} else {
cnt = 0;
while (P % tmp == 0) {
P = P / tmp;
cnt++;
}
ans *= pow(tmp, cnt / N);
tmp = 3;
while (tmp * tmp <= P) {
cnt = 0;
while (P % tmp == 0) {
P = P / tmp;
cnt++;
}
ans *= pow(tmp, cnt / N);
tmp += 2;
}
cout << ans;
}
return 0;
}
| replace | 27 | 28 | 27 | 28 | TLE | |
p03194 | C++ | Time Limit Exceeded | #include <iostream>
#include <map>
using namespace std;
typedef long long ll;
int main() {
ll n, p;
map<ll, ll> yakusuu;
cin >> n >> p;
while (p % 2 == 0) {
yakusuu[2]++;
p /= 2;
}
for (int i = 3; i * i <= p; i += 2) {
while (p % i == 0) {
yakusuu[i]++;
p /= i;
}
}
yakusuu[p]++;
ll ans = 1;
for (auto itr = yakusuu.begin(); itr != yakusuu.end(); itr++) {
ll x = itr->second / n;
while (x--)
ans *= itr->first;
}
cout << ans << endl;
return 0;
}
| #include <iostream>
#include <map>
using namespace std;
typedef long long ll;
int main() {
ll n, p;
map<ll, ll> yakusuu;
cin >> n >> p;
while (p % 2 == 0) {
yakusuu[2]++;
p /= 2;
}
for (ll i = 3; i * i <= p; i += 2) {
while (p % i == 0) {
yakusuu[i]++;
p /= i;
}
}
yakusuu[p]++;
ll ans = 1;
for (auto itr = yakusuu.begin(); itr != yakusuu.end(); itr++) {
ll x = itr->second / n;
while (x--)
ans *= itr->first;
}
cout << ans << endl;
return 0;
}
| replace | 13 | 14 | 13 | 14 | TLE | |
p03194 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
const int N = 501;
const int mod = 1e9 + 7;
int main() {
long long n, p;
long long ans = 1;
scanf("%lld %lld", &n, &p);
for (int i = 2; i * i <= p; i++) {
if (p % i)
continue;
int cnt = 0;
while (p % i == 0) {
p /= i;
cnt++;
if (cnt == n) {
ans *= i;
cnt = 0;
}
}
}
if (p > 1 && n == 1) {
ans *= p;
}
printf("%lld\n", ans);
return 0;
} | #include <bits/stdc++.h>
using namespace std;
const int N = 501;
const int mod = 1e9 + 7;
int main() {
long long n, p;
long long ans = 1;
scanf("%lld %lld", &n, &p);
for (int i = 2; 1LL * i * i <= p; i++) {
if (p % i)
continue;
int cnt = 0;
while (p % i == 0) {
p /= i;
cnt++;
if (cnt == n) {
ans *= i;
cnt = 0;
}
}
}
if (p > 1 && n == 1) {
ans *= p;
}
printf("%lld\n", ans);
return 0;
} | replace | 8 | 9 | 8 | 9 | TLE | |
p03194 | C++ | Runtime Error | /* -*- coding: utf-8 -*-
*
* c.cc: C - Product and GCD
*/
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
/* constant */
/* typedef */
typedef long long ll;
/* global variables */
/* subroutines */
ll powll(ll a, ll b) {
ll p = 1;
while (b > 0) {
if (b & 1LL)
p *= a;
a *= a;
b >>= 1;
}
return p;
}
/* main */
int main() {
ll n, p;
scanf("%lld%lld", &n, &p);
if (n == 1)
printf("%lld\n", p);
else {
ll gcd = 1;
for (ll k = 2;; k++) {
ll e = powll(k, n);
if (p < e)
break;
if (p % e == 0)
gcd = k;
}
printf("%lld\n", gcd);
}
return 0;
}
| /* -*- coding: utf-8 -*-
*
* c.cc: C - Product and GCD
*/
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;
/* constant */
/* typedef */
typedef long long ll;
/* global variables */
/* subroutines */
ll powll(ll a, ll b) {
ll p = 1;
while (b > 0) {
if (b & 1LL)
p *= a;
a *= a;
b >>= 1;
}
return p;
}
/* main */
int main() {
ll n, p;
scanf("%lld%lld", &n, &p);
if (n == 1)
printf("%lld\n", p);
else if (n >= 40)
puts("1");
else {
ll gcd = 1;
for (ll k = 2;; k++) {
ll e = powll(k, n);
if (p < e)
break;
if (p % e == 0)
gcd = k;
}
printf("%lld\n", gcd);
}
return 0;
}
| insert | 55 | 55 | 55 | 57 | 0 | |
p03194 | C++ | Runtime Error | /*
オーダー
10**6 余裕を持って間に合う
10**7 おそらく間に合う 余裕を持って間に合う
10**8 非常にシンプルな処理でない限り厳しい おそらく間に合う
10**9 非常にシンプルな処理でない限り厳しい
logn :OK
n :10^7
nlogn :10^6
n**2 :10^4
n**3 :300
2**n :20
n! :10
// 各桁の和を計算する関数
int findSumOfDigits(int n) {
int sum = 0;
while (n > 0) { // n が 0 になるまで
sum += n % 10;
n /= 10;
}
return sum;
}
sort(a, a + N, greater<int>()); // a[0:N] を大きい順にソート
int num[110] = {0}; // バケット
for (int i = 0; i < N; ++i) {
num[d[i]]++; // d[i] が 1 個増える
}
map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
auto itr = mp.find(s[i]); // s[i] が設定されているか?
if(itr != mp.end() ) {
mp[s[i]] += 1;
}
else {
mp[s[i]] += 1 ;
}
}
stack<int> s; //intをデータとするスタックを用意
s.push(1); //{} -> {1}
printf("%d\n", s.top()); // 3
s.pop();
queue<int> que; //intをデータとするキューを用意
que.push(1); //{} -> {1}
printf("%d\n", que.front()); // 1
que.pop();
*/
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll, ll> P;
#define REP(i, n) for (long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
// int amari = 0;
// int keta = 0;
// while (n > 0) { // n が 0 になるまで
// amari += n % 2;
// if (keta%2==0)
// n /= 10;
// }
// return sum;
// }
int main() {
// 入力
ll N, P;
cin >> N >> P;
// 解法
bool f[2000001]; // 素数かどうかの判別リスト, falseなら素数、もしくは未確認
for (ll i = 2; i <= 2000001; i++) { // 2-10000までの整数に対し
if (!f[i]) {
// f[i]=0ならばiはまだ見ていない=iは素数である。
// !f[i]: iが素数であるなら
for (ll j = i + i; j <= 2000001; j += i) { // iの倍数jに対し
f[j] = true; // iの倍数jが素数でないことを記録する。
}
}
}
if (N == 1)
cout << P << endl;
else {
ll ans = 1;
ll i = 2;
while ((ll)pow(i, N) <= P) {
ll count = 0;
if (!f[i]) {
ll count = 0;
while (P % i == 0) {
count++;
P /= i;
}
if (count / N >= 1)
ans *= (ll)pow(i, count / N);
// printf("P: %lld i: %lld ans: %lld\n", P, i, ans);
}
i++;
}
// 出力
cout << ans << endl;
}
// cout << (ll)pow(206,N) << endl;
// cout << 972439611840/(ll)pow(206,N) << endl;
// cout << (ll)pow(206,N)*540 << endl;
}
| /*
オーダー
10**6 余裕を持って間に合う
10**7 おそらく間に合う 余裕を持って間に合う
10**8 非常にシンプルな処理でない限り厳しい おそらく間に合う
10**9 非常にシンプルな処理でない限り厳しい
logn :OK
n :10^7
nlogn :10^6
n**2 :10^4
n**3 :300
2**n :20
n! :10
// 各桁の和を計算する関数
int findSumOfDigits(int n) {
int sum = 0;
while (n > 0) { // n が 0 になるまで
sum += n % 10;
n /= 10;
}
return sum;
}
sort(a, a + N, greater<int>()); // a[0:N] を大きい順にソート
int num[110] = {0}; // バケット
for (int i = 0; i < N; ++i) {
num[d[i]]++; // d[i] が 1 個増える
}
map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
auto itr = mp.find(s[i]); // s[i] が設定されているか?
if(itr != mp.end() ) {
mp[s[i]] += 1;
}
else {
mp[s[i]] += 1 ;
}
}
stack<int> s; //intをデータとするスタックを用意
s.push(1); //{} -> {1}
printf("%d\n", s.top()); // 3
s.pop();
queue<int> que; //intをデータとするキューを用意
que.push(1); //{} -> {1}
printf("%d\n", que.front()); // 1
que.pop();
*/
#include <algorithm>
#include <bitset>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll, ll> P;
#define REP(i, n) for (long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18
// int
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
// int amari = 0;
// int keta = 0;
// while (n > 0) { // n が 0 になるまで
// amari += n % 2;
// if (keta%2==0)
// n /= 10;
// }
// return sum;
// }
int main() {
// 入力
ll N, P;
cin >> N >> P;
// 解法
bool f[2000001]; // 素数かどうかの判別リスト, falseなら素数、もしくは未確認
for (ll i = 2; i <= 2000001; i++) { // 2-10000までの整数に対し
if (!f[i]) {
// f[i]=0ならばiはまだ見ていない=iは素数である。
// !f[i]: iが素数であるなら
for (ll j = i + i; j <= 2000001; j += i) { // iの倍数jに対し
f[j] = true; // iの倍数jが素数でないことを記録する。
}
}
}
if (N == 1)
cout << P << endl;
else if (N >= 41)
cout << 1 << endl;
else {
ll ans = 1;
ll i = 2;
while ((ll)pow(i, N) <= P) {
ll count = 0;
if (!f[i]) {
ll count = 0;
while (P % i == 0) {
count++;
P /= i;
}
if (count / N >= 1)
ans *= (ll)pow(i, count / N);
// printf("P: %lld i: %lld ans: %lld\n", P, i, ans);
}
i++;
}
// 出力
cout << ans << endl;
}
// cout << (ll)pow(206,N) << endl;
// cout << 972439611840/(ll)pow(206,N) << endl;
// cout << (ll)pow(206,N)*540 << endl;
}
| insert | 104 | 104 | 104 | 106 | 0 | |
p03195 | C++ | Runtime Error | #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
long long n, a;
vector<long long> v;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a;
v.push_back(a);
}
vector<long long>::iterator it = v.begin();
vector<long long>::iterator it_end = v.end();
while (it != it_end) {
if (*it % 2 != 0) {
cout << "first" << endl;
exit(1);
}
it++;
}
cout << "second" << endl;
return 0;
}
| #include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
int main() {
long long n, a;
vector<long long> v;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a;
v.push_back(a);
}
vector<long long>::iterator it = v.begin();
vector<long long>::iterator it_end = v.end();
while (it != it_end) {
if (*it % 2 != 0) {
cout << "first" << endl;
return 0;
}
it++;
}
cout << "second" << endl;
return 0;
}
| replace | 20 | 21 | 20 | 21 | 1 | |
p03195 | Python | Runtime Error | N = int(input())
a = [int(input()) for _ in range(N)] * [0, 0]
a.sort()
if len(a) >= 2:
res = a[-2]
else:
res = a[-1]
res += sum(a[:-2])
print("second" if res % 2 == 0 else "first")
| N = int(input())
a = [int(input()) % 2 for _ in range(N)]
res = sum(a)
print("first" if res > 0 else "second")
| replace | 1 | 9 | 1 | 4 | TypeError: can't multiply sequence by non-int of type 'list' | Traceback (most recent call last):
File "/home/alex/Documents/bug-detection/input/Project_CodeNet/data/p03195/Python/s025451632.py", line 2, in <module>
a = [int(input()) for _ in range(N)] * [0, 0]
TypeError: can't multiply sequence by non-int of type 'list'
|
p03196 | C++ | Time Limit Exceeded | #include <algorithm>
#include <bitset>
#include <iostream>
#include <math.h>
#include <queue>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <utility>
#include <vector>
#define mp make_pair
#define pb push_back
#define pm % 1000000007
#define llc (long long)
#define ldc (long double)
#define poc __builtin_popcount
using namespace std;
int modex(int b, int e) {
int h = 1;
while (e) {
if (e & 1)
h = llc h * b pm;
b = llc b * b pm;
e >>= 1;
}
return h;
}
int main() {
long long n, p, res = 1;
int ctr;
cin >> n >> p;
for (int i = 2; i * i <= p; i++) {
if (p % i == 0) {
ctr = 0;
while (p % i == 0) {
ctr++;
p /= i;
}
ctr /= n;
while (ctr--) {
res *= i;
}
}
}
if (p != 1 && n == 1)
res *= p;
printf("%lld\n", res);
}
| #include <algorithm>
#include <bitset>
#include <iostream>
#include <math.h>
#include <queue>
#include <stack>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <utility>
#include <vector>
#define mp make_pair
#define pb push_back
#define pm % 1000000007
#define llc (long long)
#define ldc (long double)
#define poc __builtin_popcount
using namespace std;
int modex(int b, int e) {
int h = 1;
while (e) {
if (e & 1)
h = llc h * b pm;
b = llc b * b pm;
e >>= 1;
}
return h;
}
int main() {
long long n, p, res = 1;
int ctr;
cin >> n >> p;
for (int i = 2; llc i * i <= p; i++) {
if (p % i == 0) {
ctr = 0;
while (p % i == 0) {
ctr++;
p /= i;
}
ctr /= n;
while (ctr--) {
res *= i;
}
}
}
if (p != 1 && n == 1)
res *= p;
printf("%lld\n", res);
}
| replace | 33 | 34 | 33 | 34 | TLE | |
p03196 | C++ | Time Limit Exceeded | #include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x, y) make_pair(x, y)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define wr cout << "----------------" << endl;
#define ppb() pop_back()
#define tr(ii, c) \
for (__typeof((c).begin()) ii = (c).begin(); ii != (c).end(); ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x) cerr << #x << " = " << x << endl;
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
template <class T> bool umin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool umax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
int main() {
// freopen("file.in", "r", stdin);
ll n, p;
cin >> n >> p;
if (n == 1)
cout << p << endl;
else {
int ans = 0;
for (int i = 1; i; i++) {
ll cur = 1;
bool f = 1;
for (int j = 0; j < n; j++) {
cur *= i;
if (cur > p) {
f = 0;
break;
}
}
if (!f)
break;
if (p % cur == 0)
ans = i;
}
printf("%d\n", ans);
}
return 0;
}
| #include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x, y) make_pair(x, y)
#define all(v) v.begin(), v.end()
#define pb(x) push_back(x)
#define wr cout << "----------------" << endl;
#define ppb() pop_back()
#define tr(ii, c) \
for (__typeof((c).begin()) ii = (c).begin(); ii != (c).end(); ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x) cerr << #x << " = " << x << endl;
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
template <class T> bool umin(T &a, T b) {
if (a > b) {
a = b;
return 1;
}
return 0;
}
template <class T> bool umax(T &a, T b) {
if (a < b) {
a = b;
return 1;
}
return 0;
}
int main() {
// freopen("file.in", "r", stdin);
ll n, p;
cin >> n >> p;
if (n == 1)
cout << p << endl;
else {
int ans = 1;
for (int i = 2; i; i++) {
ll cur = 1;
bool f = 1;
for (int j = 0; j < n; j++) {
cur *= i;
if (cur > p) {
f = 0;
break;
}
}
if (!f)
break;
if (p % cur == 0)
ans = i;
}
printf("%d\n", ans);
}
return 0;
}
| replace | 39 | 41 | 39 | 41 | TLE | |
p03196 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9) + 7;
const double pi = acos(-1);
#define rep0(i, n) for (ll(i) = 0; (i) < (n); ++(i))
#define rrep0(i, n) for (ll(i) = (n)-1; (i) >= 0; --(i))
#define rep1(i, n) for (ll(i) = 1; (i) <= (n); ++(i))
#define rrep1(i, n) for (ll(i) = (n); (i) >= 1; --(i))
#define nfor(i, a, b) for (ll(i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(), (x).end()
#define yes pf("Yes")
#define no pf("No")
ll gcd(ll a, ll b) {
if (a < b)
swap(a, b);
if (b == 0)
return a;
return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
ll g = gcd(a, b);
return a / g * b;
}
ll factorial(ll n) {
ll t = 1;
rep1(i, n) {
t *= i;
t %= mod;
}
return t;
}
ll power(ll a, ll b) {
a %= mod;
if (b == 0) {
return 1;
}
ll ans = power(a, b / 2);
ans = ans * ans % mod;
if (b % 2 == 1) {
ans = ans * a % mod;
}
return ans;
}
ll combination(ll a, ll b) {
if ((a == b) || (b == 0)) {
return 1;
}
if (a < b)
return 0;
ll ans = 1;
for (ll i = 0; i < b; i++) {
ans *= (a - i);
ans /= (i + 1);
ans %= mod;
}
return ans;
}
int main() {
ll n, p, ans = 1;
cin >> n >> p;
if (n == 1) {
pf(p);
return 0;
}
for (ll i = 2; i <= p; ++i) {
ll cnt = 0;
while (p % i == 0) {
++cnt;
p /= i;
}
if (cnt >= n)
ans *= power(i, (cnt / n));
if (i >= 3)
++i;
}
pf(ans);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e12);
const ll mod = ll(1e9) + 7;
const double pi = acos(-1);
#define rep0(i, n) for (ll(i) = 0; (i) < (n); ++(i))
#define rrep0(i, n) for (ll(i) = (n)-1; (i) >= 0; --(i))
#define rep1(i, n) for (ll(i) = 1; (i) <= (n); ++(i))
#define rrep1(i, n) for (ll(i) = (n); (i) >= 1; --(i))
#define nfor(i, a, b) for (ll(i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(), (x).end()
#define yes pf("Yes")
#define no pf("No")
ll gcd(ll a, ll b) {
if (a < b)
swap(a, b);
if (b == 0)
return a;
return gcd(b, a % b);
}
ll lcm(ll a, ll b) {
ll g = gcd(a, b);
return a / g * b;
}
ll factorial(ll n) {
ll t = 1;
rep1(i, n) {
t *= i;
t %= mod;
}
return t;
}
ll power(ll a, ll b) {
a %= mod;
if (b == 0) {
return 1;
}
ll ans = power(a, b / 2);
ans = ans * ans % mod;
if (b % 2 == 1) {
ans = ans * a % mod;
}
return ans;
}
ll combination(ll a, ll b) {
if ((a == b) || (b == 0)) {
return 1;
}
if (a < b)
return 0;
ll ans = 1;
for (ll i = 0; i < b; i++) {
ans *= (a - i);
ans /= (i + 1);
ans %= mod;
}
return ans;
}
int main() {
ll n, p, ans = 1;
cin >> n >> p;
if (n == 1) {
pf(p);
return 0;
}
for (ll i = 2; i * i <= p; ++i) {
ll cnt = 0;
while (p % i == 0) {
++cnt;
p /= i;
}
if (cnt >= n)
ans *= power(i, (cnt / n));
if (i >= 3)
++i;
}
pf(ans);
return 0;
}
| replace | 73 | 74 | 73 | 74 | TLE | |
p03196 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
using i64 = std::int_fast64_t;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
i64 N, P;
cin >> N >> P;
map<i64, int> cnts;
for (int i = 2; i * i < P + 1; i++) {
int cnt = 0;
while (P % i == 0) {
P /= i;
cnt++;
}
if (cnt > 0)
cnts[i] = cnt;
}
if (P > 1)
cnts[P]++;
i64 res = 1;
for (auto it = cnts.begin(); it != cnts.end(); it++) {
res *= pow(it->first, it->second / N);
}
cout << res << '\n';
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
using i64 = std::int_fast64_t;
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
i64 N, P;
cin >> N >> P;
map<i64, int> cnts;
for (i64 i = 2; i * i < P + 1; i++) {
int cnt = 0;
while (P % i == 0) {
P /= i;
cnt++;
}
if (cnt > 0)
cnts[i] = cnt;
}
if (P > 1)
cnts[P]++;
i64 res = 1;
for (auto it = cnts.begin(); it != cnts.end(); it++) {
res *= pow(it->first, it->second / N);
}
cout << res << '\n';
return 0;
}
| replace | 11 | 12 | 11 | 12 | TLE | |
p03196 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 5;
inline ll read() {
ll x = 0, w = 1;
char ch = 0;
while (ch < '0' || ch > '9') {
ch = getchar();
if (ch == '-')
w = -1;
}
while (ch <= '9' && ch >= '0') {
x = (x << 1) + (x << 3) + ch - '0';
ch = getchar();
}
return x * w;
}
inline ll Pow(ll x, ll y) {
ll res = 1;
while (y) {
if (y & 1)
res = res * x;
x = x * x;
y >>= 1;
}
return res;
}
ll n, p, ans;
int main() {
n = read(), p = read(), ans = 1;
if (n == 1) {
printf("%lld\n", p);
return 0;
}
for (int i = 2; i * i <= p; ++i) {
if (p == 1)
break;
if (!(p % i)) {
ll cnt = 0;
while (!(p % i))
++cnt, p /= i;
for (int j = 1; j <= cnt / n; ++j)
ans *= i;
}
}
printf("%lld\n", ans);
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 5;
inline ll read() {
ll x = 0, w = 1;
char ch = 0;
while (ch < '0' || ch > '9') {
ch = getchar();
if (ch == '-')
w = -1;
}
while (ch <= '9' && ch >= '0') {
x = (x << 1) + (x << 3) + ch - '0';
ch = getchar();
}
return x * w;
}
inline ll Pow(ll x, ll y) {
ll res = 1;
while (y) {
if (y & 1)
res = res * x;
x = x * x;
y >>= 1;
}
return res;
}
ll n, p, ans;
int main() {
n = read(), p = read(), ans = 1;
if (n == 1) {
printf("%lld\n", p);
return 0;
}
for (ll i = 2; i * i <= p; ++i) {
if (p == 1)
break;
if (!(p % i)) {
ll cnt = 0;
while (!(p % i))
++cnt, p /= i;
for (int j = 1; j <= cnt / n; ++j)
ans *= i;
}
}
printf("%lld\n", ans);
return 0;
} | replace | 35 | 36 | 35 | 36 | TLE | |
p03196 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {
os << "[";
for (const auto &v : vec) {
os << v << ",";
}
os << "]";
return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
os << "(" << p.first << ", " << p.second << ")";
return os;
}
ll N, P;
ll mypow(ll x, ll n) {
ll res = 1;
while (n > 0) {
if (n & 1)
res = res * x;
if (res > P)
return -1;
x = x * x;
n >>= 1;
}
if (res > P)
return -1;
return res;
}
void solve() {
cin >> N >> P;
ll ans = 0;
for (ll i = 1; i * i <= P; i++) {
if (P % i == 0) {
ll j = P / i;
if (N == 1) {
ans = max(ans, i);
if (P % j == 0)
ans = max(ans, j);
} else {
ll P_ = P;
bool ok1 = true, ok2 = true;
for (ll k = 0; k < N; k++) {
if (P_ % i == 0) {
P_ /= i;
} else {
ok1 = false;
break;
}
if (P_ == 0) {
ok1 = false;
break;
}
}
P_ = P;
for (ll k = 0; k < N; k++) {
if (P_ % j == 0) {
P_ /= j;
} else {
ok2 = false;
break;
}
if (P_ == 0) {
ok2 = false;
break;
}
}
if (ok1)
ans = max(ans, i);
if (ok2)
ans = max(ans, j);
}
}
}
cout << ans << endl;
}
int main() {
std::cin.tie(0);
std::ios::sync_with_stdio(false);
cout.setf(ios::fixed);
cout.precision(16);
solve();
return 0;
} | #include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); i++)
constexpr int MOD = 1000000007;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
constexpr int dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, -1, 1};
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec) {
os << "[";
for (const auto &v : vec) {
os << v << ",";
}
os << "]";
return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
os << "(" << p.first << ", " << p.second << ")";
return os;
}
ll N, P;
ll mypow(ll x, ll n) {
ll res = 1;
while (n > 0) {
if (n & 1)
res = res * x;
if (res > P)
return -1;
x = x * x;
n >>= 1;
}
if (res > P)
return -1;
return res;
}
void solve() {
cin >> N >> P;
ll ans = 0;
for (ll i = 1; i * i <= P; i++) {
if (P % i == 0) {
ll j = P / i;
if (N == 1) {
ans = max(ans, i);
if (P % j == 0)
ans = max(ans, j);
} else {
ll P_ = P;
bool ok1 = true, ok2 = true;
if (i != 1) {
for (ll k = 0; k < N; k++) {
if (P_ % i == 0) {
P_ /= i;
} else {
ok1 = false;
break;
}
if (P_ == 0) {
ok1 = false;
break;
}
}
}
P_ = P;
for (ll k = 0; k < N; k++) {
if (P_ % j == 0) {
P_ /= j;
} else {
ok2 = false;
break;
}
if (P_ == 0) {
ok2 = false;
break;
}
}
if (ok1)
ans = max(ans, i);
if (ok2)
ans = max(ans, j);
}
}
}
cout << ans << endl;
}
int main() {
std::cin.tie(0);
std::ios::sync_with_stdio(false);
cout.setf(ios::fixed);
cout.precision(16);
solve();
return 0;
} | replace | 59 | 69 | 59 | 71 | TLE | |
p03196 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll n, p, ans;
cin >> n >> p;
if (n == 1) {
cout << p << endl;
return 0;
}
for (ll i = 1; i <= p; i++) {
ll gcd = pow(i, n);
if (p % gcd == 0) {
ans = i;
} else if (gcd > p) {
break;
}
}
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll n, p, ans;
cin >> n >> p;
if (n == 1) {
cout << p << endl;
return 0;
}
if (n > 40) {
cout << 1 << endl;
return 0;
}
for (ll i = 1; i <= p; i++) {
ll gcd = pow(i, n);
if (p % gcd == 0) {
ans = i;
} else if (gcd > p) {
break;
}
}
cout << ans << endl;
return 0;
}
| insert | 8 | 8 | 8 | 12 | TLE | |
p03196 | C++ | Time Limit Exceeded | #include <algorithm>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(c) c.begin(), c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
int main() {
ll N, P;
cin >> N >> P;
ll i = 2, gcd = 1;
ll count;
while (pow(i, N) <= P) {
count = 0;
while (true) {
if (P % i == 0) {
count++;
P /= i;
} else {
gcd *= ll(pow(i, (count / N)));
break;
}
}
if (i == 2) {
i++;
} else {
i += 2;
}
}
cout << gcd;
return 0;
}
| #include <algorithm>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long int ll;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(c) c.begin(), c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
int main() {
ll N, P;
cin >> N >> P;
ll i = 2, gcd = 1;
ll count;
if (N == 1) {
cout << P;
return 0;
}
while (pow(i, 2) <= P) {
count = 0;
while (true) {
if (P % i == 0) {
count++;
P /= i;
} else {
gcd *= ll(pow(i, (count / N)));
break;
}
}
if (i == 2) {
i++;
} else {
i += 2;
}
}
cout << gcd;
return 0;
}
| replace | 41 | 42 | 41 | 47 | TLE | |
p03196 | C++ | Time Limit Exceeded | #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template <class S, class T>
ostream &operator<<(ostream &out, const pair<S, T> &o) {
out << "(" << o.first << "," << o.second << ")";
return out;
}
template <class T> ostream &operator<<(ostream &out, const vector<T> V) {
for (int i = 0; i < V.size(); i++) {
out << V[i];
if (i != V.size() - 1)
out << " ";
}
return out;
}
template <class T>
ostream &operator<<(ostream &out, const vector<vector<T>> Mat) {
for (int i = 0; i < Mat.size(); i++) {
if (i != 0)
out << endl;
out << Mat[i];
}
return out;
}
template <class S, class T>
ostream &operator<<(ostream &out, const map<S, T> mp) {
out << "{ ";
for (auto it = mp.begin(); it != mp.end(); it++) {
out << it->first << ":" << it->second;
if (mp.size() - 1 != distance(mp.begin(), it))
out << ", ";
}
out << " }";
return out;
}
/*
<url:>
問題文============================================================
=================================================================
解説=============================================================
================================================================
*/
/* 素因数分解 */
void PrimeFact(ll n, map<ll, ll> &mp) {
while (n != 1) {
if (n == 2 || n == 3) {
mp[n]++;
n /= n;
continue;
}
bool prime_flag = false;
for (int i = 2; i * i <= n; i++) {
if (n % i == 0) {
mp[i]++;
n /= i;
prime_flag = true;
break;
}
}
if (!prime_flag) {
mp[n]++;
n /= n;
}
}
}
const ll MOD = LLONG_MAX;
ll powmod(ll a, ll b) {
ll res = 1;
a %= MOD;
for (; b; b >>= 1) {
if (b & 1)
res = res * a % MOD;
a = a * a % MOD;
}
return res;
}
template <class Type> Type solve(Type res = Type()) {
ll N, P;
cin >> N >> P;
map<ll, ll> mp;
PrimeFact(P, mp);
res = 1;
for (auto p : mp) {
if (p.second >= N) {
res *= powmod(p.first, p.second / N);
}
}
return res;
}
int main(void) {
cin.tie(0);
ios_base::sync_with_stdio(false);
// solve(0);
cout << fixed << setprecision(15) << solve<ll>() << endl;
return 0;
}
| #include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
template <class S, class T>
ostream &operator<<(ostream &out, const pair<S, T> &o) {
out << "(" << o.first << "," << o.second << ")";
return out;
}
template <class T> ostream &operator<<(ostream &out, const vector<T> V) {
for (int i = 0; i < V.size(); i++) {
out << V[i];
if (i != V.size() - 1)
out << " ";
}
return out;
}
template <class T>
ostream &operator<<(ostream &out, const vector<vector<T>> Mat) {
for (int i = 0; i < Mat.size(); i++) {
if (i != 0)
out << endl;
out << Mat[i];
}
return out;
}
template <class S, class T>
ostream &operator<<(ostream &out, const map<S, T> mp) {
out << "{ ";
for (auto it = mp.begin(); it != mp.end(); it++) {
out << it->first << ":" << it->second;
if (mp.size() - 1 != distance(mp.begin(), it))
out << ", ";
}
out << " }";
return out;
}
/*
<url:>
問題文============================================================
=================================================================
解説=============================================================
================================================================
*/
/* 素因数分解 */
void PrimeFact(ll n, map<ll, ll> &mp) {
while (n != 1) {
if (n == 2 || n == 3) {
mp[n]++;
n /= n;
continue;
}
bool prime_flag = false;
for (ll i = 2; i * i <= n; i++) {
if (n % i == 0) {
mp[i]++;
n /= i;
prime_flag = true;
break;
}
}
if (!prime_flag) {
mp[n]++;
n /= n;
}
}
}
const ll MOD = LLONG_MAX;
ll powmod(ll a, ll b) {
ll res = 1;
a %= MOD;
for (; b; b >>= 1) {
if (b & 1)
res = res * a % MOD;
a = a * a % MOD;
}
return res;
}
template <class Type> Type solve(Type res = Type()) {
ll N, P;
cin >> N >> P;
map<ll, ll> mp;
PrimeFact(P, mp);
res = 1;
for (auto p : mp) {
if (p.second >= N) {
res *= powmod(p.first, p.second / N);
}
}
return res;
}
int main(void) {
cin.tie(0);
ios_base::sync_with_stdio(false);
// solve(0);
cout << fixed << setprecision(15) << solve<ll>() << endl;
return 0;
}
| replace | 60 | 61 | 60 | 61 | TLE | |
p03196 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N, P;
ll mx = 1;
int main() {
scanf("%lld%lld", &N, &P);
for (int i = 2; i * i <= P; ++i) {
int cnt = 0;
while (!(P % i)) {
cnt++;
if (!(cnt % N))
mx *= i;
P /= i;
}
}
if (N == 1)
mx *= P;
printf("%lld\n", mx);
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll N, P;
ll mx = 1;
int main() {
scanf("%lld%lld", &N, &P);
for (ll i = 2; i * i <= P; ++i) {
int cnt = 0;
while (!(P % i)) {
cnt++;
if (!(cnt % N))
mx *= i;
P /= i;
}
}
if (N == 1)
mx *= P;
printf("%lld\n", mx);
} | replace | 11 | 12 | 11 | 12 | TLE | |
p03196 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
ll mod = 1e9 + 7;
map<ll, ll> prime_factor(ll n) {
map<ll, ll> res;
for (int i = 2; i * i <= n; i++) {
while (n % i == 0) {
res[i]++;
n /= i;
}
}
if (n != 1) {
res[n]++;
}
return res;
}
ll mpow(ll x, ll n) {
ll ans = 1;
while (n > 0) {
if (n & 1) {
ans = ans * x;
}
x = x * x;
n >>= 1;
}
return ans;
}
int main() {
ll n, p;
cin >> n >> p;
ll ans = 1;
map<ll, ll> c = prime_factor(p);
for (auto p : c) {
ll temp = p.second / n;
ans *= mpow(p.first, temp);
}
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
ll mod = 1e9 + 7;
map<ll, ll> prime_factor(ll n) {
map<ll, ll> res;
for (ll i = 2; i * i <= n; i++) {
while (n % i == 0) {
res[i]++;
n /= i;
}
}
if (n != 1) {
res[n]++;
}
return res;
}
ll mpow(ll x, ll n) {
ll ans = 1;
while (n > 0) {
if (n & 1) {
ans = ans * x;
}
x = x * x;
n >>= 1;
}
return ans;
}
int main() {
ll n, p;
cin >> n >> p;
ll ans = 1;
map<ll, ll> c = prime_factor(p);
for (auto p : c) {
ll temp = p.second / n;
ans *= mpow(p.first, temp);
}
cout << ans << endl;
} | replace | 8 | 9 | 8 | 9 | TLE | |
p03196 | C++ | Time Limit Exceeded | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
typedef pair<ll, ll> cp2;
typedef pair<ll, cp2> cp3;
#define fi first
#define se second
#define sec se.fi
#define thr se.se
const ll mod = 1000000007;
// 123456789
///////////////////////////////////////////////
//
//
///////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
ll N;
ll P;
ll ans = 1;
ll x = 2;
ll num;
ll calc(ll a, ll b) {
ll res = 1;
ll temp = a;
while (b) {
if (b % 2)
res *= temp;
if (res > P) {
res = mod * mod;
break;
}
temp = temp * temp;
b /= 2;
}
return res;
}
int main() {
cin >> N >> P;
num = calc(x, N);
if (N > 50) {
puts("1");
} else {
while (num <= P) {
if (P % num == 0)
ans = x;
// cout<<x<<";"<<num<<endl;
x++;
num = calc(x, N);
}
cout << ans << endl;
}
return 0;
} | #include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
typedef pair<ll, ll> cp2;
typedef pair<ll, cp2> cp3;
#define fi first
#define se second
#define sec se.fi
#define thr se.se
const ll mod = 1000000007;
// 123456789
///////////////////////////////////////////////
//
//
///////////////////////////////////////////////
////////////////////////////////////////////////
////////////////////////////////////////////////
ll N;
ll P;
ll ans = 1;
ll x = 2;
ll num;
ll calc(ll a, ll b) {
ll res = 1;
ll temp = a;
while (b) {
if (b % 2)
res *= temp;
if (res > P) {
res = mod * mod;
break;
}
temp = temp * temp;
b /= 2;
}
return res;
}
int main() {
cin >> N >> P;
num = calc(x, N);
if (N > 50) {
puts("1");
} else if (N == 1) {
cout << P << endl;
} else {
while (num <= P) {
if (P % num == 0)
ans = x;
// cout<<x<<";"<<num<<endl;
x++;
num = calc(x, N);
}
cout << ans << endl;
}
return 0;
} | insert | 64 | 64 | 64 | 66 | TLE | |
p03196 | C++ | Time Limit Exceeded | #include <algorithm>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <utility>
#include <vector>
#include <vector>
#define ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define ll long long
#define pb push_back
using namespace std;
const int N = 2e6, PI = 3.14159265359, M = 1e9 + 7;
typedef pair<ll, ll> pii;
map<ll, ll> dp;
ll a[N], ans = 0;
map<pii, ll> ma;
vector<pii> v, v1;
int main() {
ll n, p;
cin >> n >> p;
for (int i = 2; i * i <= p; i++) {
if (p % i == 0) {
ll cnt = 0;
while (p % i == 0) {
p /= i;
cnt++;
}
v.pb({i, cnt});
}
}
if (p != 1) {
v.pb({p, 1});
}
ll ans = 1;
for (int i = 0; i < v.size(); i++) {
ll t = v[i].ss / n;
while (t--) {
ans *= v[i].ff;
}
}
cout << ans;
return 0;
} | #include <algorithm>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <utility>
#include <vector>
#include <vector>
#define ss second
#define ff first
#define use_fast ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define ret(n) return cout << n, 0
#define se(n) cout << setprecision(n) << fixed
#define ll long long
#define pb push_back
using namespace std;
const int N = 2e6, PI = 3.14159265359, M = 1e9 + 7;
typedef pair<ll, ll> pii;
map<ll, ll> dp;
ll a[N], ans = 0;
map<pii, ll> ma;
vector<pii> v, v1;
int main() {
ll n, p;
cin >> n >> p;
for (ll int i = 2; i * i <= p; i++) {
if (p % i == 0) {
ll cnt = 0;
while (p % i == 0) {
p /= i;
cnt++;
}
v.pb({i, cnt});
}
}
if (p != 1) {
v.pb({p, 1});
}
ll ans = 1;
for (int i = 0; i < v.size(); i++) {
ll t = v[i].ss / n;
while (t--) {
ans *= v[i].ff;
}
}
cout << ans;
return 0;
} | replace | 32 | 33 | 32 | 33 | TLE | |
p03196 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define ALL(c) (c).begin(), (c).end()
#define dump(x) cout << #x << " = " << (x) << endl
ll N, P;
int main() {
ll a = 1;
cin >> N >> P;
if (N == 1) {
cout << P << endl;
return 0;
}
for (int i = 2; i * i <= P; ++i) {
if (P % i == 0) {
int c = 0;
while (P % i == 0) {
P /= i;
++c;
}
c /= N;
rep(tt, c) { a = a * i; }
}
}
cout << a << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define ALL(c) (c).begin(), (c).end()
#define dump(x) cout << #x << " = " << (x) << endl
ll N, P;
int main() {
ll a = 1;
cin >> N >> P;
if (N == 1) {
cout << P << endl;
return 0;
}
for (ll i = 2; i * i <= P; ++i) {
if (P % i == 0) {
int c = 0;
while (P % i == 0) {
P /= i;
++c;
}
c /= N;
rep(tt, c) { a = a * i; }
}
}
cout << a << endl;
return 0;
} | replace | 27 | 28 | 27 | 28 | TLE | |
p03196 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
const int maxN = 2e5 + 10;
const int INF = 999999999;
ll n, p;
ll a[maxN];
ll q[maxN];
struct node {
ll x, t;
};
ll tot = 0ll;
ll power(ll x, ll t) {
if (t == 0)
return 1;
ll y = power(x, t / 2);
y = y * y;
if (t % 2 == 1)
y = y * x;
return y;
}
bool check(ll x) {
if (p % (power(x, n)) == 0)
return true;
else
return false;
}
int main() {
scanf("%lld%lld", &n, &p);
if (n == 1) {
printf("%lld\n", p);
return 0;
}
ll ans = 0;
for (ll i = 1; power(i, n) <= p; i++) {
if (p % (power(i, n)) == 0)
ans = max(ans, i);
}
printf("%lld\n", ans);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
const int maxN = 2e5 + 10;
const int INF = 999999999;
ll n, p;
ll a[maxN];
ll q[maxN];
struct node {
ll x, t;
};
ll tot = 0ll;
ll power(ll x, ll t) {
if (t == 0)
return 1;
ll y = power(x, t / 2);
y = y * y;
if (t % 2 == 1)
y = y * x;
return y;
}
bool check(ll x) {
if (p % (power(x, n)) == 0)
return true;
else
return false;
}
int main() {
scanf("%lld%lld", &n, &p);
if (n == 1) {
printf("%lld\n", p);
return 0;
}
ll ans = 0;
for (ll i = 1; n * log(i) <= log(p) + 1; i++) {
if (p % (power(i, n)) == 0)
ans = max(ans, i);
}
printf("%lld\n", ans);
return 0;
}
| replace | 41 | 42 | 41 | 42 | 0 | |
p03196 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n, p, cnt = 1;
ll ans, tmp;
int main() {
cin >> n >> p;
if (n == 1) {
cout << p << endl;
return 0;
}
while (1) {
tmp = 1;
for (long long i = 1; i <= n; i++)
tmp *= cnt;
if (tmp > p)
break;
if (p % tmp == 0)
ans = cnt;
cnt++;
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
#define ll long long
using namespace std;
ll n, p, cnt = 1;
ll ans, tmp;
int main() {
cin >> n >> p;
if (n >= 50) {
cout << 1 << endl;
return 0;
}
if (n == 1) {
cout << p << endl;
return 0;
}
while (1) {
tmp = 1;
for (long long i = 1; i <= n; i++)
tmp *= cnt;
if (tmp > p)
break;
if (p % tmp == 0)
ans = cnt;
cnt++;
}
cout << ans << endl;
return 0;
} | insert | 7 | 7 | 7 | 11 | TLE | |
p03196 | C++ | Time Limit Exceeded | /*** Template Begin ***/
#pragma region template
#define USING_NAMESPACE
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
typedef int64_t i64;
typedef uint64_t u64;
auto init_ = [] {
std::ios_base::sync_with_stdio(false);
std::cout << std::fixed;
return 0;
}();
template <typename T> inline void in(T &x) { std::cin >> x; }
template <typename T, typename... Ts> inline void in(T &t, Ts &...ts) {
std::cin >> t;
in(ts...);
}
template <typename T, typename U = std::vector<T>> inline U vin(int n) {
U v(n);
for (int i = 0; i < n; ++i) {
std::cin >> v[i];
}
return v;
}
template <typename T, typename U = std::vector<T>, typename V = std::vector<U>>
inline V vin(int h, int w) {
V vv(h, U(w));
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
std::cin >> vv[i][j];
}
}
return vv;
}
template <typename T> inline void out(const T &x) {
std::cout << x << std::endl;
}
template <char delimiter = ' ', typename T, typename... Ts>
inline void out(const T &t, const Ts &...ts) {
std::cout << t << delimiter;
out(ts...);
}
template <char delimiter = ' ', typename T>
inline void vout(const T &v, int n) {
for (int i = 0; i < n; ++i) {
if (i)
std::cout << delimiter;
std::cout << v[i];
}
std::cout << std::endl;
}
template <char delimiter = ' ', typename T>
inline void vout(const T &v, int h, int w) {
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
if (j)
std::cout << delimiter;
std::cout << v[i][j];
}
std::cout << std::endl;
}
}
template <typename T, size_t D> struct multi_vector_type {
using type = std::vector<typename multi_vector_type<T, D - 1>::type>;
};
template <typename T> struct multi_vector_type<T, 1> {
using type = std::vector<T>;
};
template <typename T> struct multi_vector_type<T, 0> {
using type = T;
};
template <typename T, size_t D>
using multi_vector = typename multi_vector_type<T, D>::type;
template <typename T, size_t D, class = typename std::enable_if<D == 0>::type>
T make_vector(const T &val = T()) {
return val;
}
template <typename T, size_t D = 1, typename... Ts,
class = typename std::enable_if<D != 0>::type>
multi_vector<T, D> make_vector(size_t n, Ts &&...args) {
return multi_vector<T, D>(n, make_vector<T, D - 1>(args...));
}
namespace detail {
template <typename F> struct Debug {
const char *delim_ = "\n";
F fun;
Debug(F f) : fun(f) {}
~Debug() { fun(delim_); }
Debug &delim(const char *d) {
delim_ = d;
return *this;
}
};
std::deque<std::string> split(const std::string &s, char c) {
std::deque<std::string> v;
std::stringstream ss(s);
std::string x;
while (std::getline(ss, x, c))
v.emplace_back(x);
return v;
}
template <typename T>
void deb(const char *delim, std::deque<std::string> v, T a) {
std::cerr << v[0].substr(v[0][0] == ' ', v[0].length()) << " = " << a << '\n';
std::cerr << std::flush;
}
template <typename T, typename... Args>
void deb(const char *delim, std::deque<std::string> v, T a, Args... args) {
std::cerr << v[0].substr(v[0][0] == ' ', v[0].length()) << " = " << a
<< delim;
v.pop_front();
deb(delim, std::move(v), args...);
}
template <typename... Args> auto wrap(std::deque<std::string> v, Args... args) {
auto f = [=](const char *delim = "\n") { deb(delim, v, args...); };
return Debug<decltype(f)>(f);
}
} // namespace detail
#define debug(args...) ::detail::wrap(::detail::split(#args, ','), args)
#ifdef USING_BOOST
#include <boost/math/common_factor.hpp>
#include <boost/range.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/algorithm_ext.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/numeric.hpp>
inline auto rep(int begin, int end) {
if (begin > end) {
return boost::irange(0, 0);
} else {
return boost::irange(begin, end);
}
}
inline auto rep(int begin, int end, int step) {
if ((step > 0 && begin > end) || (step < 0 && begin < end)) {
return boost::irange(0, 0, step);
} else {
return boost::irange(begin, end, step);
}
}
#endif
#ifdef USING_NAMESPACE
using namespace std;
#ifdef USING_BOOST
using namespace boost;
using namespace boost::adaptors;
#endif
#endif
#pragma endregion
/*** Template End ***/
int main() {
i64 n, p;
in(n, p);
map<i64, int> m;
for (int i = 2; i * i <= p; i++) {
while (p % i == 0) {
p /= i;
m[i]++;
}
}
if (p != 1) {
m[p]++;
}
i64 ans = 1;
for (auto &x : m) {
i64 num = x.first;
int cnt = x.second;
while (cnt >= n) {
ans *= num;
cnt -= n;
}
}
out(ans);
} | /*** Template Begin ***/
#pragma region template
#define USING_NAMESPACE
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
typedef int64_t i64;
typedef uint64_t u64;
auto init_ = [] {
std::ios_base::sync_with_stdio(false);
std::cout << std::fixed;
return 0;
}();
template <typename T> inline void in(T &x) { std::cin >> x; }
template <typename T, typename... Ts> inline void in(T &t, Ts &...ts) {
std::cin >> t;
in(ts...);
}
template <typename T, typename U = std::vector<T>> inline U vin(int n) {
U v(n);
for (int i = 0; i < n; ++i) {
std::cin >> v[i];
}
return v;
}
template <typename T, typename U = std::vector<T>, typename V = std::vector<U>>
inline V vin(int h, int w) {
V vv(h, U(w));
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
std::cin >> vv[i][j];
}
}
return vv;
}
template <typename T> inline void out(const T &x) {
std::cout << x << std::endl;
}
template <char delimiter = ' ', typename T, typename... Ts>
inline void out(const T &t, const Ts &...ts) {
std::cout << t << delimiter;
out(ts...);
}
template <char delimiter = ' ', typename T>
inline void vout(const T &v, int n) {
for (int i = 0; i < n; ++i) {
if (i)
std::cout << delimiter;
std::cout << v[i];
}
std::cout << std::endl;
}
template <char delimiter = ' ', typename T>
inline void vout(const T &v, int h, int w) {
for (int i = 0; i < h; ++i) {
for (int j = 0; j < w; ++j) {
if (j)
std::cout << delimiter;
std::cout << v[i][j];
}
std::cout << std::endl;
}
}
template <typename T, size_t D> struct multi_vector_type {
using type = std::vector<typename multi_vector_type<T, D - 1>::type>;
};
template <typename T> struct multi_vector_type<T, 1> {
using type = std::vector<T>;
};
template <typename T> struct multi_vector_type<T, 0> {
using type = T;
};
template <typename T, size_t D>
using multi_vector = typename multi_vector_type<T, D>::type;
template <typename T, size_t D, class = typename std::enable_if<D == 0>::type>
T make_vector(const T &val = T()) {
return val;
}
template <typename T, size_t D = 1, typename... Ts,
class = typename std::enable_if<D != 0>::type>
multi_vector<T, D> make_vector(size_t n, Ts &&...args) {
return multi_vector<T, D>(n, make_vector<T, D - 1>(args...));
}
namespace detail {
template <typename F> struct Debug {
const char *delim_ = "\n";
F fun;
Debug(F f) : fun(f) {}
~Debug() { fun(delim_); }
Debug &delim(const char *d) {
delim_ = d;
return *this;
}
};
std::deque<std::string> split(const std::string &s, char c) {
std::deque<std::string> v;
std::stringstream ss(s);
std::string x;
while (std::getline(ss, x, c))
v.emplace_back(x);
return v;
}
template <typename T>
void deb(const char *delim, std::deque<std::string> v, T a) {
std::cerr << v[0].substr(v[0][0] == ' ', v[0].length()) << " = " << a << '\n';
std::cerr << std::flush;
}
template <typename T, typename... Args>
void deb(const char *delim, std::deque<std::string> v, T a, Args... args) {
std::cerr << v[0].substr(v[0][0] == ' ', v[0].length()) << " = " << a
<< delim;
v.pop_front();
deb(delim, std::move(v), args...);
}
template <typename... Args> auto wrap(std::deque<std::string> v, Args... args) {
auto f = [=](const char *delim = "\n") { deb(delim, v, args...); };
return Debug<decltype(f)>(f);
}
} // namespace detail
#define debug(args...) ::detail::wrap(::detail::split(#args, ','), args)
#ifdef USING_BOOST
#include <boost/math/common_factor.hpp>
#include <boost/range.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/algorithm_ext.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/numeric.hpp>
inline auto rep(int begin, int end) {
if (begin > end) {
return boost::irange(0, 0);
} else {
return boost::irange(begin, end);
}
}
inline auto rep(int begin, int end, int step) {
if ((step > 0 && begin > end) || (step < 0 && begin < end)) {
return boost::irange(0, 0, step);
} else {
return boost::irange(begin, end, step);
}
}
#endif
#ifdef USING_NAMESPACE
using namespace std;
#ifdef USING_BOOST
using namespace boost;
using namespace boost::adaptors;
#endif
#endif
#pragma endregion
/*** Template End ***/
int main() {
i64 n, p;
in(n, p);
map<i64, int> m;
for (i64 i = 2; i * i <= p; i++) {
while (p % i == 0) {
p /= i;
m[i]++;
}
}
if (p != 1) {
m[p]++;
}
i64 ans = 1;
for (auto &x : m) {
i64 num = x.first;
int cnt = x.second;
while (cnt >= n) {
ans *= num;
cnt -= n;
}
}
out(ans);
} | replace | 222 | 223 | 222 | 223 | TLE | |
p03196 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)), UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a + mod - b) % mod
#define MUL(a, b) a = (a * b) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i, m, n) for (int i = m; i < n; i++)
#define drep(i, n, m) for (int i = n; i >= m; i--)
#define rep(i, n) repi(i, 0, n)
#define rrep(i, n) repi(i, 1, n + 1)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
os << "(" << p.first << "," << p.second << ")";
return os;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
for (auto it = v.begin(); it != v.end(); ++it) {
if (it != v.begin())
os << " ";
os << *it;
}
return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp) {
for (auto x : mp)
os << "(" << x.first << "," << x.second << ")" << endl;
return os;
}
template <typename T, int SIZE> int array_length(const T (&)[SIZE]) {
return SIZE;
}
template <typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true) {
if (t == -1) {
rep(i, s) {
if (i)
cout << " ";
cout << a[i];
}
} else
repi(i, s, t) {
if (i != s)
cout << " ";
cout << a[i];
}
if (f)
cout << "\n";
}
template <typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2) {
rep(i, h) {
rep(j, w) { cout << a[i][j] << " \n"[j == w - 1]; }
}
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9 + 7;
const int INF = 1e18 + 7;
int a[2000000];
map<int, int> mp;
int Pow(int x, int y) {
int res = 1;
rep(i, inf) {
if (y == 0)
break;
if (y & 1)
res *= x;
y >>= 1;
x *= x;
}
return res;
}
signed main() {
int n, p;
scanf("%lld%lld", &n, &p);
if (n == 1) {
printf("%lld\n", p);
return 0;
}
int pp = p;
repi(i, 2, inf) {
if (pp == 1)
break;
while (pp % i == 0) {
// printf("*%lld %lld*\n", i, pp);
mp[i]++;
pp /= i;
}
}
for (auto it = mp.begin(); it != mp.end(); it++) {
// printf("%lld %lld\n", it->fi, it->se);
}
int ans = 1;
for (auto it = mp.begin(); it != mp.end(); it++) {
ans *= Pow(it->fi, (it->se / n));
}
printf("%lld\n", ans);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
// define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)), UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a + mod - b) % mod
#define MUL(a, b) a = (a * b) % mod
#define rollcall cout << "I'm Sucu." << endl;
#define repi(i, m, n) for (int i = m; i < n; i++)
#define drep(i, n, m) for (int i = n; i >= m; i--)
#define rep(i, n) repi(i, 0, n)
#define rrep(i, n) repi(i, 1, n + 1)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x, y) make_pair(x, y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define fi first
#define se second
// debug
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
os << "(" << p.first << "," << p.second << ")";
return os;
}
template <typename T> ostream &operator<<(ostream &os, const vector<T> &v) {
for (auto it = v.begin(); it != v.end(); ++it) {
if (it != v.begin())
os << " ";
os << *it;
}
return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp) {
for (auto x : mp)
os << "(" << x.first << "," << x.second << ")" << endl;
return os;
}
template <typename T, int SIZE> int array_length(const T (&)[SIZE]) {
return SIZE;
}
template <typename T, int N>
void PRINTF(const T (&a)[N], int s = N, int t = -1, bool f = true) {
if (t == -1) {
rep(i, s) {
if (i)
cout << " ";
cout << a[i];
}
} else
repi(i, s, t) {
if (i != s)
cout << " ";
cout << a[i];
}
if (f)
cout << "\n";
}
template <typename T, int N1, int N2>
void PRINTF(const T (&a)[N1][N2], int h = N1, int w = N2) {
rep(i, h) {
rep(j, w) { cout << a[i][j] << " \n"[j == w - 1]; }
}
}
// typedef
typedef complex<double> Point;
typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9 + 7;
const int INF = 1e18 + 7;
int a[2000000];
map<int, int> mp;
int Pow(int x, int y) {
int res = 1;
rep(i, inf) {
if (y == 0)
break;
if (y & 1)
res *= x;
y >>= 1;
x *= x;
}
return res;
}
signed main() {
int n, p;
scanf("%lld%lld", &n, &p);
if (n == 1) {
printf("%lld\n", p);
return 0;
}
int pp = p;
repi(i, 2, 2000000) {
if (pp == 1)
break;
while (pp % i == 0) {
// printf("*%lld %lld*\n", i, pp);
mp[i]++;
pp /= i;
}
}
for (auto it = mp.begin(); it != mp.end(); it++) {
// printf("%lld %lld\n", it->fi, it->se);
}
int ans = 1;
for (auto it = mp.begin(); it != mp.end(); it++) {
ans *= Pow(it->fi, (it->se / n));
}
printf("%lld\n", ans);
return 0;
}
| replace | 103 | 104 | 103 | 104 | TLE | |
p03196 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Vec = vector<ll>;
#define FOR(i, m, n) for (ll(i) = (m); (i) < (n); (i)++)
#define FORN(i, m, n) for (ll(i) = (m); (i) <= (n); (i)++)
#define FORR(i, m, n) for (ll(i) = (m); (i) >= (n); (i)--)
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FORN(i, 1, n)
#define repr(i, n) FORR(i, n, 0)
#define repnr(i, n) FORR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
const ll INF = 1e9 + 1;
const ll LINF = 1e18 + 1;
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;
int main(void) {
ll n, p;
cin >> n >> p;
if (n == 1) {
co(p);
return 0;
}
ll ans = 0;
repn(i, p) {
ll num = 1;
rep(j, n) num *= i;
if (num > p)
break;
else if (!(p % num))
ans = i;
}
co(ans);
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Vec = vector<ll>;
#define FOR(i, m, n) for (ll(i) = (m); (i) < (n); (i)++)
#define FORN(i, m, n) for (ll(i) = (m); (i) <= (n); (i)++)
#define FORR(i, m, n) for (ll(i) = (m); (i) >= (n); (i)--)
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FORN(i, 1, n)
#define repr(i, n) FORR(i, n, 0)
#define repnr(i, n) FORR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
const ll INF = 1e9 + 1;
const ll LINF = 1e18 + 1;
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;
int main(void) {
ll n, p;
cin >> n >> p;
if (n == 1) {
co(p);
return 0;
} else if (n >= 50) {
co(1);
return 0;
}
ll ans = 0;
repn(i, p) {
ll num = 1;
rep(j, n) num *= i;
if (num > p)
break;
else if (!(p % num))
ans = i;
}
co(ans);
return 0;
}
| insert | 34 | 34 | 34 | 37 | TLE | |
p03196 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define mod 1000000007 // 10^9+7
#define INF 1000000000000 // 10^12
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < n; i++)
int n, p;
int ans = 1, x = 1;
signed main() {
cin >> n >> p;
for (int i = 2; x <= p; i++) {
x = 1;
for (int j = 0; j < n; j++) {
x *= i;
if (x > p) {
cout << ans << endl;
return 0;
}
}
if (p % x == 0)
ans = i;
}
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define mod 1000000007 // 10^9+7
#define INF 1000000000000 // 10^12
#define P pair<int, int>
#define rep(i, n) for (int i = 0; i < n; i++)
int n, p;
int ans = 1, x = 1;
signed main() {
cin >> n >> p;
if (n == 1) {
cout << p << endl;
return 0;
}
for (int i = 2; x <= p; i++) {
x = 1;
for (int j = 0; j < n; j++) {
x *= i;
if (x > p) {
cout << ans << endl;
return 0;
}
}
if (p % x == 0)
ans = i;
}
cout << ans << endl;
return 0;
}
| insert | 12 | 12 | 12 | 16 | TLE | |
p03196 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main() {
long long N, P;
cin >> N >> P;
long long r = 1;
if (N == 1) {
r = P;
} else {
for (int i = 2; i * i <= P; ++i) {
int c = 0;
while (P % i == 0) {
++c;
P /= i;
}
for (int j = 0; j < c / N; ++j)
r *= i;
}
}
cout << r << endl;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
long long N, P;
cin >> N >> P;
long long r = 1;
if (N == 1) {
r = P;
} else {
for (long long i = 2; i * i <= P; ++i) {
int c = 0;
while (P % i == 0) {
++c;
P /= i;
}
for (int j = 0; j < c / N; ++j)
r *= i;
}
}
cout << r << endl;
}
| replace | 9 | 10 | 9 | 10 | TLE | |
p03196 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define int long long
#define ggr \
getchar(); \
getchar(); \
return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int> P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template <class T> inline void chmax(T &a, T b) { a = std::max(a, b); }
template <class T> inline void chmin(T &a, T b) { a = std::min(a, b); }
// combination(Nが小さい時はこれを使う)
const int MAX = 300000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % mod;
inv[i] = mod - inv[mod % i] * (mod / i) % mod;
finv[i] = finv[i - 1] * inv[i] % mod;
}
}
int COMB(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
bool prime(int n) {
int cnt = 0;
for (int i = 1; i <= sqrt(n); i++) {
if (n % i == 0)
cnt++;
}
if (cnt != 1)
return false;
else
return n != 1;
}
int gcd(int x, int y) {
if (y == 0)
return x;
return gcd(y, x % y);
}
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// 繰り返し二乗法(Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
int res = 1;
while (y) {
if (y & 1) {
res = res * x % m;
}
x = x * x % m;
y >>= 1;
}
return res;
}
int kai(int x, int y) {
int res = 1;
for (int i = x - y + 1; i <= x; i++) {
res *= (i % mod);
res %= mod;
}
return res;
}
int comb(int x, int y) {
if (y > x)
return 0;
return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
// UnionFind
class UnionFind {
protected:
int *par, *rank, *size;
public:
UnionFind(unsigned int size) {
par = new int[size];
rank = new int[size];
this->size = new int[size];
rep(i, size) {
par[i] = i;
rank[i] = 0;
this->size[i] = 1;
}
}
int find(int n) {
if (par[n] == n)
return n;
return par[n] = find(par[n]);
}
void unite(int n, int m) {
n = find(n);
m = find(m);
if (n == m)
return;
if (rank[n] < rank[m]) {
par[n] = m;
size[m] += size[n];
} else {
par[m] = n;
size[n] += size[m];
if (rank[n] == rank[m])
rank[n]++;
}
}
bool same(int n, int m) { return find(n) == find(m); }
int getsize(int n) { return size[find(n)]; }
};
map<int, int> mp;
signed main() {
int n, p;
cin >> n >> p;
int memo = p, ans = 1;
for (int i = 2; i <= sqrt(p); i++) {
if (prime(i)) {
while (memo % i == 0) {
memo /= i;
mp[i]++;
}
}
}
if (memo != 1)
mp[memo]++;
for (auto x : mp)
ans *= pow(x.first, x.second / n);
cout << ans << endl;
ggr
}
| #include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
#define int long long
#define ggr \
getchar(); \
getchar(); \
return 0;
#define prique priority_queue
constexpr auto mod = 1000000007;
#define inf 1e15
#define key 1e9
using namespace std;
typedef pair<int, int> P;
void yes() { cout << "Yay!" << endl; }
void no() { cout << ":(" << endl; }
template <class T> inline void chmax(T &a, T b) { a = std::max(a, b); }
template <class T> inline void chmin(T &a, T b) { a = std::min(a, b); }
// combination(Nが小さい時はこれを使う)
const int MAX = 300000;
int fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % mod;
inv[i] = mod - inv[mod % i] * (mod / i) % mod;
finv[i] = finv[i - 1] * inv[i] % mod;
}
}
int COMB(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
bool prime(int n) {
int cnt = 0;
for (int i = 1; i <= sqrt(n); i++) {
if (n % i == 0)
cnt++;
}
if (cnt != 1)
return false;
else
return n != 1;
}
int gcd(int x, int y) {
if (y == 0)
return x;
return gcd(y, x % y);
}
int lcm(int x, int y) { return x / gcd(x, y) * y; }
// 繰り返し二乗法(Nが大きい時の場合のcombination)
int mod_pow(int x, int y, int m) {
int res = 1;
while (y) {
if (y & 1) {
res = res * x % m;
}
x = x * x % m;
y >>= 1;
}
return res;
}
int kai(int x, int y) {
int res = 1;
for (int i = x - y + 1; i <= x; i++) {
res *= (i % mod);
res %= mod;
}
return res;
}
int comb(int x, int y) {
if (y > x)
return 0;
return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}
// UnionFind
class UnionFind {
protected:
int *par, *rank, *size;
public:
UnionFind(unsigned int size) {
par = new int[size];
rank = new int[size];
this->size = new int[size];
rep(i, size) {
par[i] = i;
rank[i] = 0;
this->size[i] = 1;
}
}
int find(int n) {
if (par[n] == n)
return n;
return par[n] = find(par[n]);
}
void unite(int n, int m) {
n = find(n);
m = find(m);
if (n == m)
return;
if (rank[n] < rank[m]) {
par[n] = m;
size[m] += size[n];
} else {
par[m] = n;
size[n] += size[m];
if (rank[n] == rank[m])
rank[n]++;
}
}
bool same(int n, int m) { return find(n) == find(m); }
int getsize(int n) { return size[find(n)]; }
};
map<int, int> mp;
signed main() {
int n, p;
cin >> n >> p;
int memo = p, ans = 1;
for (int i = 2; i <= sqrt(p); i++) {
while (memo % i == 0) {
memo /= i;
mp[i]++;
}
}
if (memo != 1)
mp[memo]++;
for (auto x : mp)
ans *= pow(x.first, x.second / n);
cout << ans << endl;
ggr
}
| replace | 136 | 141 | 136 | 139 | TLE | |
p03196 | C++ | Runtime Error | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
ll n, p;
cin >> n >> p;
vector<ll> div;
for (ll i = 1; i * i <= p; i++) {
if (p % i == 0) {
div.push_back(i);
div.push_back(p / i);
}
}
ll ans = 1;
for (ll now : div) {
if (now == 1)
continue;
ll cnt = 0;
ll d = now;
while (p % d == 0) {
cnt++;
d *= now;
}
if (cnt >= n)
ans = max(ans, now);
}
cout << ans << endl;
} | #include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int main() {
ll n, p;
cin >> n >> p;
vector<ll> div;
for (ll i = 1; i * i <= p; i++) {
if (p % i == 0) {
div.push_back(i);
div.push_back(p / i);
}
}
ll ans = 1;
for (ll now : div) {
if (now == 1)
continue;
ll cnt = 0;
ll pp = p;
while (true) {
if (pp % now == 0) {
cnt++;
pp /= now;
} else
break;
}
if (cnt >= n)
ans = max(ans, now);
}
cout << ans << endl;
} | replace | 31 | 35 | 31 | 38 | 0 | |
p03196 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#define _repargs(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rep(...) _repargs(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T> inline void output(T a, int p = 0) {
if (p)
cout << fixed << setprecision(p) << a << "\n";
else
cout << a << "\n";
}
// end of template
ll P;
bool po(ll a, ll b) {
ll c = 1;
rep(i, b) { c *= a; }
return c;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(0);
// source code
int N;
cin >> N;
ll ret = 1;
ll P;
cin >> P;
if (N > 40) {
output(1);
return 0;
}
ll a = 2;
while (1) {
ll b = 1;
ll ok = true;
rep(i, N) {
b *= a;
if (b > P) {
ok = false;
break;
}
}
if (!ok)
break;
if (P % b == 0) {
ret = a;
}
a++;
}
output(ret);
return 0;
}
| #include <algorithm>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#define _repargs(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rep(...) _repargs(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T> inline void output(T a, int p = 0) {
if (p)
cout << fixed << setprecision(p) << a << "\n";
else
cout << a << "\n";
}
// end of template
ll P;
bool po(ll a, ll b) {
ll c = 1;
rep(i, b) { c *= a; }
return c;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(0);
// source code
int N;
cin >> N;
ll ret = 1;
ll P;
cin >> P;
if (N == 1) {
output(P);
return 0;
}
if (N > 40) {
output(1);
return 0;
}
ll a = 2;
while (1) {
ll b = 1;
ll ok = true;
rep(i, N) {
b *= a;
if (b > P) {
ok = false;
break;
}
}
if (!ok)
break;
if (P % b == 0) {
ret = a;
}
a++;
}
output(ret);
return 0;
}
| insert | 49 | 49 | 49 | 53 | TLE | |
p03196 | C++ | Time Limit Exceeded | #ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)
#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;
/*
ll pw(ll a, ll b) {
ll ans = 1; while (b) {
while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
ans = (ans * a) % MOD, --b;
} return ans;
}
*/
ll n, p;
int main() {
#ifdef FASTIO
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
cin >> p >> n;
ll ans = 1;
for (int i = 2; i * i <= n; ++i) {
if (n % i != 0)
continue;
int cnt = 0;
while (n % i == 0)
n /= i, ++cnt;
while (cnt >= p)
cnt -= p, ans *= i;
}
if (n != 1 && p == 1)
ans *= n;
cout << ans << "\n";
return 0;
}
| #ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>
#define FASTIO
#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)
#ifdef FASTIO
#define scanf abacaba
#define printf abacaba
#endif
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
using namespace std;
/*
ll pw(ll a, ll b) {
ll ans = 1; while (b) {
while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
ans = (ans * a) % MOD, --b;
} return ans;
}
*/
ll n, p;
int main() {
#ifdef FASTIO
ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#endif
cin >> p >> n;
ll ans = 1;
for (ll i = 2; i * i <= n; ++i) {
if (n % i != 0)
continue;
int cnt = 0;
while (n % i == 0)
n /= i, ++cnt;
while (cnt >= p)
cnt -= p, ans *= i;
}
if (n != 1 && p == 1)
ans *= n;
cout << ans << "\n";
return 0;
}
| replace | 37 | 38 | 37 | 38 | TLE | |
p03196 | C++ | Time Limit Exceeded | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<ll, int> P;
int main() {
ll n, p;
cin >> n >> p;
vector<P> v;
for (int i = 2; i * i <= p; i++) {
if (p % i == 0) {
int e = 0;
while (p % i == 0) {
p /= i;
e++;
}
v.push_back(P(i, e));
}
}
if (p > 1)
v.push_back(P(p, 1));
ll ans = 1;
for (int i = 0; i < v.size(); i++) {
int e = v[i].second;
ll q = v[i].first;
for (int j = 0; j < e / n; j++) {
ans *= q;
}
}
cout << ans << endl;
return 0;
} | #include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long int ll;
typedef pair<ll, int> P;
int main() {
ll n, p;
cin >> n >> p;
vector<P> v;
for (ll i = 2; i * i <= p; i++) {
if (p % i == 0) {
int e = 0;
while (p % i == 0) {
p /= i;
e++;
}
v.push_back(P(i, e));
}
}
if (p > 1)
v.push_back(P(p, 1));
ll ans = 1;
for (int i = 0; i < v.size(); i++) {
int e = v[i].second;
ll q = v[i].first;
for (int j = 0; j < e / n; j++) {
ans *= q;
}
}
cout << ans << endl;
return 0;
} | replace | 25 | 26 | 25 | 26 | TLE | |
p03196 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm = 1000000000;
ll MM = mm + 7;
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.141592653589793
int main() {
ll n, p;
cin >> n >> p;
if (n == 1)
cout << p << endl;
else {
ll i = 0;
ll ans;
ll k = 0;
while (k <= p) {
i++;
k = pow(i, n);
if (p % k == 0)
ans = i;
}
cout << ans << endl;
}
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm = 1000000000;
ll MM = mm + 7;
#define rep(i, n) for (int i = 0; i < n; i++)
#define PI 3.141592653589793
int main() {
ll n, p;
cin >> n >> p;
if (n == 1)
cout << p << endl;
else if (n >= 50)
cout << 1 << endl;
else {
ll i = 0;
ll ans;
ll k = 0;
while (k <= p) {
i++;
k = pow(i, n);
if (p % k == 0)
ans = i;
}
cout << ans << endl;
}
} | insert | 15 | 15 | 15 | 17 | TLE | |
p03196 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
using lint = long long;
vector<long long> d;
int main(void) {
lint n;
cin >> n;
long long p;
cin >> p;
if (n == 1) {
cout << p << endl;
return 0;
}
for (int i = 2; i * i <= p; i++) {
while (p % i == 0) {
d.push_back(i);
p /= i;
}
}
if (p != 1)
d.push_back(p);
int cnt = 1;
lint ans = 1;
for (int i = 0; i < (int)d.size() - 1; i++) {
if (d[i] == d[i + 1]) {
cnt++;
} else {
if (cnt >= n)
ans *= pow(d[i], (cnt / n));
cnt = 1;
}
if (i == (int)d.size() - 2) {
if (cnt >= n)
ans *= pow(d[i], (cnt / n));
}
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
using lint = long long;
vector<long long> d;
int main(void) {
lint n;
cin >> n;
long long p;
cin >> p;
if (n == 1) {
cout << p << endl;
return 0;
}
for (long long i = 2; i * i <= p; i++) {
while (p % i == 0) {
d.push_back(i);
p /= i;
}
}
if (p != 1)
d.push_back(p);
int cnt = 1;
lint ans = 1;
for (int i = 0; i < (int)d.size() - 1; i++) {
if (d[i] == d[i + 1]) {
cnt++;
} else {
if (cnt >= n)
ans *= pow(d[i], (cnt / n));
cnt = 1;
}
if (i == (int)d.size() - 2) {
if (cnt >= n)
ans *= pow(d[i], (cnt / n));
}
}
cout << ans << endl;
return 0;
} | replace | 13 | 14 | 13 | 14 | TLE | |
p03196 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll n, p, ans = 1;
cin >> n >> p;
if (n == 1) {
cout << p << endl;
return 0;
}
for (int i = 2; i * i <= p; i++) {
if (p % i != 0)
continue;
ll num = 0;
while (p % i == 0) {
p /= i;
num++;
if (num == n) {
ans *= i;
num = 0;
}
}
}
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll n, p, ans = 1;
cin >> n >> p;
if (n == 1) {
cout << p << endl;
return 0;
}
for (ll i = 2; i * i <= p; i++) {
ll num = 0;
while (p % i == 0) {
p /= i;
num++;
if (num == n) {
ans *= i;
num = 0;
}
}
}
cout << ans << endl;
} | replace | 12 | 15 | 12 | 13 | TLE | |
p03196 | C++ | Time Limit Exceeded |
#include <bits/stdc++.h>
#define x first
#define y second
#define mp make_pair
// everything goes according to my plan
#define pb push_back
#define sz(a) (int)(a.size())
#define vec vector
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
#define y1 Y_U_NO_y1
#define left Y_U_NO_left
#define right Y_U_NO_right
#ifdef Local
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr \
if (0) \
cout
#endif
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap() {
ios_base ::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
inline void randomizer3000() {
unsigned int seed;
asm("rdtsc" : "=A"(seed));
srand(seed);
}
void files(string problem) {
if (fopen((problem + ".in").c_str(), "r")) {
freopen((problem + ".in").c_str(), "r", stdin);
freopen((problem + ".out").c_str(), "w", stdout);
}
}
void localInput(const char in[] = "s") {
if (fopen(in, "r")) {
freopen(in, "r", stdin);
} else
cerr << "Warning: Input file not found" << endl;
}
int main() {
#ifdef Local
// localInput();
#endif
Read_rap();
ll n, p;
cin >> n >> p;
if (n == 1) {
cout << p;
return 0;
}
ll ans = 1;
for (ll x = 1; x * x <= p; x++) {
ll y = x;
for (int j = 1; j <= n && y <= p && p % y == 0; j++, y *= x) {
if (j == n)
ans = x;
}
}
cout << ans;
return 0;
}
// Coded by Z..
|
#include <bits/stdc++.h>
#define x first
#define y second
#define mp make_pair
// everything goes according to my plan
#define pb push_back
#define sz(a) (int)(a.size())
#define vec vector
// shimkenttin kyzdary, dzyn, dzyn, dzyn...
#define y1 Y_U_NO_y1
#define left Y_U_NO_left
#define right Y_U_NO_right
#ifdef Local
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr \
if (0) \
cout
#endif
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
typedef long double ld;
const int Mod = (int)1e9 + 7;
const int MX = 1073741822;
const ll MXLL = 4e18;
const int Sz = 1110111;
// a pinch of soul
inline void Read_rap() {
ios_base ::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
}
inline void randomizer3000() {
unsigned int seed;
asm("rdtsc" : "=A"(seed));
srand(seed);
}
void files(string problem) {
if (fopen((problem + ".in").c_str(), "r")) {
freopen((problem + ".in").c_str(), "r", stdin);
freopen((problem + ".out").c_str(), "w", stdout);
}
}
void localInput(const char in[] = "s") {
if (fopen(in, "r")) {
freopen(in, "r", stdin);
} else
cerr << "Warning: Input file not found" << endl;
}
int main() {
#ifdef Local
// localInput();
#endif
Read_rap();
ll n, p;
cin >> n >> p;
if (n == 1) {
cout << p;
return 0;
}
ll ans = 1;
for (ll x = 2; x * x <= p; x++) {
ll y = x;
for (int j = 1; j <= n && y <= p && p % y == 0; j++, y *= x) {
if (j == n)
ans = x;
}
}
cout << ans;
return 0;
}
// Coded by Z..
| replace | 71 | 72 | 71 | 72 | TLE | |
p03196 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll n, p;
cin >> n >> p;
ll r = 1;
if (n < 40) {
for (int i = 1; i <= p; i++) {
ll x = pow(i, n);
if (x > p) {
break;
}
if (p % x == 0) {
r = i;
}
}
}
cout << r << endl;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
ll n, p;
cin >> n >> p;
ll r = 1;
if (n == 1) {
r = p;
} else if (n < 40) {
for (int i = 1; i <= p; i++) {
ll x = pow(i, n);
if (x > p) {
break;
}
if (p % x == 0) {
r = i;
}
}
}
cout << r << endl;
}
| replace | 8 | 9 | 8 | 11 | TLE | |
p03196 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll qpow(ll a, ll n) {
ll ret = 1;
while (n) {
if (n & 1)
ret = ret * a;
a = a * a;
n >>= 1;
if (ret > 1e12)
return LLONG_MAX;
}
return ret;
}
int main() {
ll n, p;
cin >> n >> p;
if (n > 40) {
puts("1");
return 0;
}
if (n == 1) {
cout << p;
return 0;
}
if (p == 1) {
puts("1");
return 0;
}
bool isp = 1;
ll yz;
for (ll i = 2; i * i <= p; i++) {
if (p % i == 0) {
isp = 0;
yz = i;
break;
}
}
if (isp) {
if (n == 1)
cout << p;
else
puts("1");
return 0;
} else {
ll ans = 1;
for (ll i = 2; i * i <= p; i++) {
if (p % i == 0) {
ll in = qpow(i, n);
if (p % in == 0) {
ans = i;
}
}
}
cout << ans;
}
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll qpow(ll a, ll n) {
ll ret = 1;
while (n) {
if (n & 1)
ret = ret * a;
a = a * a;
n >>= 1;
if (ret > 1e12)
return LLONG_MAX;
}
return ret;
}
int main() {
ll n, p;
cin >> n >> p;
if (n > 40) {
puts("1");
return 0;
}
if (n == 1) {
cout << p;
return 0;
}
if (p == 1) {
puts("1");
return 0;
}
bool isp = 1;
ll yz;
for (ll i = 2; i * i <= p; i++) {
if (p % i == 0) {
isp = 0;
yz = i;
break;
}
}
if (isp) {
if (n == 1)
cout << p;
else
puts("1");
return 0;
} else {
ll ans = 1;
for (ll i = 2; i * i <= p; i++) {
if (p % i == 0) {
ll in = qpow(i, n);
while (p % in == 0) {
p /= in;
ans *= i;
}
}
}
cout << ans;
}
return 0;
}
| replace | 51 | 53 | 51 | 54 | 0 | |
p03196 | C++ | Runtime Error | #include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
map<ll, int> prime_factor(ll n) {
map<ll, int> ret;
for (ll i = 2; i * i <= n; i++) {
while (n % i == 0) {
ret[i]++;
n /= i;
}
}
if (n != 1)
ret[n] = 1;
return ret;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll n, p;
cin >> n >> p;
map<ll, int> mp = prime_factor(p);
std::map<ll, int>::reverse_iterator i = mp.rbegin();
vector<ll> v(n, 1);
int j = 0;
for (; i != mp.rend(); ++i) {
rep(k, 0, i->second) {
v[j] *= i->first;
j++;
if (j == n)
j = 0;
}
}
ll ans = v[0];
rep(i, 1, n) { ans = __gcd(ans, v[i]); }
cout << ans << endl;
}
| #include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
map<ll, int> prime_factor(ll n) {
map<ll, int> ret;
for (ll i = 2; i * i <= n; i++) {
while (n % i == 0) {
ret[i]++;
n /= i;
}
}
if (n != 1)
ret[n] = 1;
return ret;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(0);
ll n, p;
cin >> n >> p;
map<ll, int> mp = prime_factor(p);
int c = 0;
for (auto m : mp)
c += m.second;
if (c < n) {
cout << 1 << endl;
return 0;
}
std::map<ll, int>::reverse_iterator i = mp.rbegin();
vector<ll> v(n, 1);
int j = 0;
for (; i != mp.rend(); ++i) {
rep(k, 0, i->second) {
v[j] *= i->first;
j++;
if (j == n)
j = 0;
}
}
ll ans = v[0];
rep(i, 1, n) { ans = __gcd(ans, v[i]); }
cout << ans << endl;
}
| insert | 30 | 30 | 30 | 39 | 0 | |
p03196 | C++ | Time Limit Exceeded | #include <algorithm>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
#define int long long
#define endl "\n"
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define vecin(v) \
for (int i = 0; i < (int)v.size(); i++) \
cin >> v[i];
using namespace std;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
int z00 = 1;
for (int i = 0; i < y00; i++) {
z00 *= x00;
}
return z00;
}
int keta(int x00) {
int z00 = x00;
int w00 = 0;
while (z00 != 0) {
z00 /= 10;
w00++;
}
return w00;
}
int modinv(int a, int m) {
int b = m, u = 1, v = 0;
while (b) {
int t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
u %= m;
if (u < 0)
u += m;
return u;
}
int modpow(int a, int n) {
int res = 1;
while (n > 0) {
if (n & 1)
res *a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
int gcd(int xx, int yy) {
int p = xx;
int q = yy;
if (q > p)
swap(p, q);
while (p % q != 0) {
p %= q;
swap(p, q);
}
return q;
}
int lcm(int xx, int yy) { return xx * yy / gcd(xx, yy); }
bool prime(int xx) {
int a = xx;
for (int i = 2; i * i <= xx; i++) {
if (xx % i == 0) {
return 0;
}
}
return 1;
}
int com(int xx, int yy) {
int zz = 1;
for (int i = xx; i > xx - yy; i--) {
zz *= i;
zz %= mod;
}
for (int i = 1; i <= yy; i++) {
zz *= modinv(i, mod);
zz %= mod;
}
return zz;
}
signed main() {
int a = 2, n, p, h = 0, ans = 1;
cin >> n >> p;
while (p >= a) {
if (prime(a) == 0) {
goto skip;
}
h = 0;
while (p % a == 0) {
p /= a;
h++;
}
while (h >= n) {
ans *= a;
h -= n;
}
skip:
a++;
}
cout << ans << endl;
}
| #include <algorithm>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
#define int long long
#define endl "\n"
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define vecin(v) \
for (int i = 0; i < (int)v.size(); i++) \
cin >> v[i];
using namespace std;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
int z00 = 1;
for (int i = 0; i < y00; i++) {
z00 *= x00;
}
return z00;
}
int keta(int x00) {
int z00 = x00;
int w00 = 0;
while (z00 != 0) {
z00 /= 10;
w00++;
}
return w00;
}
int modinv(int a, int m) {
int b = m, u = 1, v = 0;
while (b) {
int t = a / b;
a -= t * b;
swap(a, b);
u -= t * v;
swap(u, v);
}
u %= m;
if (u < 0)
u += m;
return u;
}
int modpow(int a, int n) {
int res = 1;
while (n > 0) {
if (n & 1)
res *a % mod;
a = a * a % mod;
n >>= 1;
}
return res;
}
int gcd(int xx, int yy) {
int p = xx;
int q = yy;
if (q > p)
swap(p, q);
while (p % q != 0) {
p %= q;
swap(p, q);
}
return q;
}
int lcm(int xx, int yy) { return xx * yy / gcd(xx, yy); }
bool prime(int xx) {
int a = xx;
for (int i = 2; i * i <= xx; i++) {
if (xx % i == 0) {
return 0;
}
}
return 1;
}
int com(int xx, int yy) {
int zz = 1;
for (int i = xx; i > xx - yy; i--) {
zz *= i;
zz %= mod;
}
for (int i = 1; i <= yy; i++) {
zz *= modinv(i, mod);
zz %= mod;
}
return zz;
}
signed main() {
int a = 2, n, p, h = 0, ans = 1;
cin >> n >> p;
if (n == 1) {
cout << p << endl;
return 0;
}
while (p >= a * a) {
if (prime(a) == 0) {
goto skip;
}
h = 0;
while (p % a == 0) {
p /= a;
h++;
}
while (h >= n) {
ans *= a;
h -= n;
}
skip:
a++;
}
cout << ans << endl;
}
| replace | 116 | 117 | 116 | 121 | TLE | |
p03196 | C++ | Runtime Error | #include <bits/stdc++.h>
#define ll long long
using namespace std;
int cot = 0;
ll n, p, a[10000005];
bool judge(ll m) {
ll ans = 1;
ll t = n;
while (t) {
if (m > p)
return false;
if (t & 1)
ans *= m;
if (ans > p || p % ans)
return false;
if (m > 1e10 && (t >> 1))
return false;
m *= m;
t >>= 1;
}
if (p % ans)
return false;
return true;
}
int main() {
a[cot++] = 1;
scanf("%lld%lld", &n, &p);
ll k = sqrt(p);
for (int i = 1; i <= k; i++)
if (p % i == 0) {
a[cot++] = i;
a[cot++] = p / i;
}
sort(a, a + cot);
ll ans = 1;
for (int i = cot - 1; i >= 0; i--)
if (judge(a[i])) {
ans = a[i];
break;
}
printf("%lld\n", ans);
}
| #include <bits/stdc++.h>
#define ll long long
using namespace std;
int cot = 0;
ll n, p, a[10000005];
bool judge(ll m) {
ll ans = 1;
ll t = n;
while (t) {
if (m > p)
return false;
if (t & 1)
ans *= m;
if (ans > p || p % ans)
return false;
if (m > 1e8 && (t >> 1))
return false;
m *= m;
t >>= 1;
}
if (p % ans)
return false;
return true;
}
int main() {
a[cot++] = 1;
scanf("%lld%lld", &n, &p);
ll k = sqrt(p);
for (int i = 1; i <= k; i++)
if (p % i == 0) {
a[cot++] = i;
a[cot++] = p / i;
}
sort(a, a + cot);
ll ans = 1;
for (int i = cot - 1; i >= 0; i--)
if (judge(a[i])) {
ans = a[i];
break;
}
printf("%lld\n", ans);
}
| replace | 15 | 16 | 15 | 16 | 0 | |
p03196 | C++ | Runtime Error | #include <bits/stdc++.h>
#define ll unsigned long long
using namespace std;
ll i, j, k, n, m, p, ans = 1;
ll Pow(ll n, ll m) {
ll ans = 1;
while (m > 1) {
if (m % 2 == 0) {
m /= 2;
n = n * n;
} else {
ans = ans * n;
m /= 2;
n = n * n;
}
}
return n * ans;
}
int main() {
cin >> p >> n;
if (p == 1) {
cout << n << endl;
return 0;
}
if (n == 1) {
cout << 1 << endl;
return 0;
}
ll ans = (ll)pow((double)n, (double)(1.0 / p));
for (i = ans + 1; i >= 2; i--) {
ll k = Pow(i, p);
if (n % k == 0) {
cout << i << endl;
return 0;
}
}
cout << 1 << endl;
return 0;
}
/*
2 999999999999
3
*/ | #include <bits/stdc++.h>
#define ll unsigned long long
using namespace std;
ll i, j, k, n, m, p, ans = 1;
ll Pow(ll n, ll m) {
ll ans = 1;
while (m > 1) {
if (m % 2 == 0) {
m /= 2;
n = n * n;
} else {
ans = ans * n;
m /= 2;
n = n * n;
}
}
return n * ans;
}
int main() {
cin >> p >> n;
if (p == 1) {
cout << n << endl;
return 0;
}
if (n == 1) {
cout << 1 << endl;
return 0;
}
ll ans = (ll)pow((double)n, (double)(1.0 / p));
for (i = ans + 1; i >= 2; i--) {
ll k = Pow(i, p);
if (k > 0 && n % k == 0) {
cout << i << endl;
return 0;
}
}
cout << 1 << endl;
return 0;
}
/*
2 999999999999
3
*/ | replace | 31 | 32 | 31 | 32 | 0 | |
p03196 | C++ | Time Limit Exceeded | #include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define FORR(i, a, b) for (int i = a; i >= b; --i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
int in() {
int x;
scanf("%d", &x);
return x;
}
ll lin() {
ll x;
scanf("%lld", &x);
return x;
}
int main() {
ll n, p;
cin >> n >> p;
if (n == 1) {
cout << p << endl;
} else {
ll ans = 1;
for (ll x = 2; x <= 1000001; x++) {
ll y = p;
bool ok = true;
REP(i, n) {
if (y % x == 0) {
y /= x;
} else {
ok = false;
}
}
if (ok)
ans = x;
}
cout << ans << endl;
}
return 0;
}
| #include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define FOR(i, a, b) for (int i = a; i <= b; ++i)
#define FORR(i, a, b) for (int i = a; i >= b; --i)
#define ALL(c) (c).begin(), (c).end()
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
int in() {
int x;
scanf("%d", &x);
return x;
}
ll lin() {
ll x;
scanf("%lld", &x);
return x;
}
int main() {
ll n, p;
cin >> n >> p;
if (n == 1) {
cout << p << endl;
} else {
ll ans = 1;
for (ll x = 2; x <= 1000001; x++) {
ll y = p;
bool ok = true;
REP(i, n) {
if (y % x == 0) {
y /= x;
} else {
ok = false;
break;
}
}
if (ok)
ans = x;
}
cout << ans << endl;
}
return 0;
}
| insert | 56 | 56 | 56 | 57 | TLE | |
p03196 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
const double eps = 1e-8;
const ll INF = 1e15;
const ll MOD = 1e9 + 7;
ll powll(ll x, ll n) {
if (n == 0)
return 1;
ll xx = powll(x, n / 2);
if (n % 2 == 0)
return xx * xx;
else
return xx * xx * x;
}
int main() {
ll N, P;
cin >> N >> P;
ll ans = 1;
for (ll k = 2; true; k++) {
ll now = powll(k, N);
if (now > P || N >= 45)
break;
while (P % now == 0) {
P /= now;
ans *= k;
}
}
cout << ans << endl;
return 0;
}
| #include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;
const double eps = 1e-8;
const ll INF = 1e15;
const ll MOD = 1e9 + 7;
ll powll(ll x, ll n) {
if (n == 0)
return 1;
ll xx = powll(x, n / 2);
if (n % 2 == 0)
return xx * xx;
else
return xx * xx * x;
}
int main() {
ll N, P;
cin >> N >> P;
ll ans = 1;
if (N == 1) {
cout << P << endl;
return 0;
}
for (ll k = 2; true; k++) {
ll now = powll(k, N);
if (now > P || N >= 45)
break;
while (P % now == 0) {
P /= now;
ans *= k;
}
}
cout << ans << endl;
return 0;
}
| insert | 44 | 44 | 44 | 48 | TLE | |
p03196 | C++ | Time Limit Exceeded | /**
* author: souzai32
* created: 12.08.2020 12:16:11
**/
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main() {
long long n, p;
cin >> n >> p;
long long gcd = 1, num, i = 2;
int count = 0;
if (n == 1)
gcd = p;
else {
while (1) {
num = pow(i, n);
if (p % num)
i++;
else {
gcd *= i;
p /= num;
}
if (num > p)
break;
// cout << num << endl;
}
}
cout << gcd << endl;
return 0;
} | /**
* author: souzai32
* created: 12.08.2020 12:16:11
**/
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main() {
long long n, p;
cin >> n >> p;
long long gcd = 1, num, i = 2;
int count = 0;
if (n == 1)
gcd = p;
else if (n >= 40)
gcd = 1;
else {
while (1) {
num = pow(i, n);
if (p % num)
i++;
else {
gcd *= i;
p /= num;
}
if (num > p)
break;
// cout << num << endl;
}
}
cout << gcd << endl;
return 0;
} | insert | 18 | 18 | 18 | 20 | TLE | |
p03196 | C++ | Time Limit Exceeded |
#include <bits/stdc++.h>
// macros
using namespace std;
typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
#define pb push_back
#define rs resize
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define repll(i, a, b) for (ll i = (a); i < (b); i++)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define COUT(a) cout << a << endl
#define ALL(a) (a).begin(), (a).end()
const long long int mod = 1e9 + 7;
int main() {
ll N, P;
ll res = 1;
map<ll, ll> list;
cin >> N >> P;
repll(i, 2, P) {
while (P % i == 0) {
list[i]++;
P /= i;
}
}
if (P != 1)
list[P]++;
for (auto i : list) {
ll common = i.second / N;
res *= pow(i.first, common);
}
COUT(res);
} |
#include <bits/stdc++.h>
// macros
using namespace std;
typedef long long ll;
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
typedef vector<ll> Vll;
#define pb push_back
#define rs resize
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define repll(i, a, b) for (ll i = (a); i < (b); i++)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define COUT(a) cout << a << endl
#define ALL(a) (a).begin(), (a).end()
const long long int mod = 1e9 + 7;
int main() {
ll N, P;
ll res = 1;
map<ll, ll> list;
cin >> N >> P;
for (ll i = 2; i * i <= P; i++) {
while (P % i == 0) {
list[i]++;
P /= i;
}
}
if (P != 1)
list[P]++;
for (auto i : list) {
ll common = i.second / N;
res *= pow(i.first, common);
}
COUT(res);
} | replace | 27 | 28 | 27 | 28 | TLE | |
p03196 | C++ | Time Limit Exceeded | // HTTF.cpp : このファイルには 'main'
// 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
#include "bits/stdc++.h"
// 実装が重そうな問題はある程度考えてから書く
// 初期化を忘れずに(特に二分探索とか)
// コーナーケースを考えて(特に場合分けとか)
// 不可解すぎるバグは配列外参照(配列の長さ)を検討
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(), YES, NO))
#define ECHO OUT(solve())
#define three(A, B, C) ((A) ? (B) : (C))
#define FOR(i, a, b) for (LL i = (a); i < (LL)(b); i++)
#define EFOR(i, a, b) for (LL i = (a); i <= (LL)(b); i++)
#define RFOR(i, a, b) for (LL i = (a); i >= (LL)(b); i--)
#define REP(i, b) FOR(i, zero, b)
#define EREP(i, b) EFOR(i, zero, b)
#define RREP(i, b) RFOR(i, b, zero)
#define ALL(c) c.begin(), c.end()
#define UNIQUE(c) \
sort(ALL(c)); \
c.erase(unique(ALL(c)), c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a, b) OUT2(a, b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a, b) cout << (a) << " " << (b) << endl
#define zero 0LL
#define int LL
#define pb emplace_back
#define eb pb
using namespace std;
template <typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template <typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template <typename T> inline bool middle(T a, T b, T c) {
return b <= a && a <= c;
}
template <class T> inline bool MX(T &l, const T &r) {
return l < r ? l = r, 1 : 0;
}
template <class T> inline bool MN(T &l, const T &r) {
return l > r ? l = r, 1 : 0;
}
typedef long long LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr, Vpr, greater<pr>> PQ;
inline void outputVI(VI x) {
REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }
OUT("");
}
const int SIZE1 = 3 * 1e5 + 1000;
const int SIZE2 = 2010;
const int SIZE3 = 400;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
const int X = 1;
const int Y = 0;
typedef pair<ld, ut> pld;
ut N, M, K, L, Q, D, H, W;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE], maps2[SIZE2][SIZE2], answer = zero;
LL maps[SIZE2][SIZE2];
LL A[SIZE], B[SIZE];
LL solve() {
LL N, P;
cin >> N >> P;
LL ans = 1;
if (N > 50)
return 1;
if (N == 1)
return P;
EFOR(i, 2, P) {
if (N * log(i) - 1000 > P)
return ans;
LL now = 1;
REP(j, N) {
if (P % i == 0)
P /= i;
else
break;
if (j == N - 1) {
ans *= i;
i--;
}
}
}
return ans;
}
signed main() {
cout << solve() << endl;
cin >> N;
return 0;
}
// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー
// 作業を開始するためのヒント:
// 1. ソリューション エクスプローラー
// ウィンドウを使用してファイルを追加/管理します
// 2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
// 3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
// 4. エラー一覧ウィンドウを使用してエラーを表示します
// 5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード
// ファイルを作成するか、[プロジェクト] > [既存の項目の追加]
// と移動して既存のコード ファイルをプロジェクトに追加します
// 6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] >
// [プロジェクト] と移動して .sln ファイルを選択します
| // HTTF.cpp : このファイルには 'main'
// 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//
#include "bits/stdc++.h"
// 実装が重そうな問題はある程度考えてから書く
// 初期化を忘れずに(特に二分探索とか)
// コーナーケースを考えて(特に場合分けとか)
// 不可解すぎるバグは配列外参照(配列の長さ)を検討
#define YES "YES"
#define NO "NO"
#define YESNO OUT(three(solve(), YES, NO))
#define ECHO OUT(solve())
#define three(A, B, C) ((A) ? (B) : (C))
#define FOR(i, a, b) for (LL i = (a); i < (LL)(b); i++)
#define EFOR(i, a, b) for (LL i = (a); i <= (LL)(b); i++)
#define RFOR(i, a, b) for (LL i = (a); i >= (LL)(b); i--)
#define REP(i, b) FOR(i, zero, b)
#define EREP(i, b) EFOR(i, zero, b)
#define RREP(i, b) RFOR(i, b, zero)
#define ALL(c) c.begin(), c.end()
#define UNIQUE(c) \
sort(ALL(c)); \
c.erase(unique(ALL(c)), c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a, b) OUT2(a, b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a, b) cout << (a) << " " << (b) << endl
#define zero 0LL
#define int LL
#define pb emplace_back
#define eb pb
using namespace std;
template <typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template <typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template <typename T> inline bool middle(T a, T b, T c) {
return b <= a && a <= c;
}
template <class T> inline bool MX(T &l, const T &r) {
return l < r ? l = r, 1 : 0;
}
template <class T> inline bool MN(T &l, const T &r) {
return l > r ? l = r, 1 : 0;
}
typedef long long LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef priority_queue<pr, Vpr, greater<pr>> PQ;
inline void outputVI(VI x) {
REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }
OUT("");
}
const int SIZE1 = 3 * 1e5 + 1000;
const int SIZE2 = 2010;
const int SIZE3 = 400;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p = 7 + 1e9;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
const int X = 1;
const int Y = 0;
typedef pair<ld, ut> pld;
ut N, M, K, L, Q, D, H, W;
// ut A,B,C,D,E,F,G,H,I,J,O,P,Q,R,T,U;
VI edges[SIZE];
LL vals[SIZE], maps2[SIZE2][SIZE2], answer = zero;
LL maps[SIZE2][SIZE2];
LL A[SIZE], B[SIZE];
LL solve() {
LL N, P;
cin >> N >> P;
LL ans = 1;
if (N > 50)
return 1;
if (N == 1)
return P;
EFOR(i, 2, P) {
if (N * log(i - 1) > log(P))
return ans;
LL now = 1;
REP(j, N) {
if (P % i == 0)
P /= i;
else
break;
if (j == N - 1) {
ans *= i;
i--;
}
}
}
return ans;
}
signed main() {
cout << solve() << endl;
cin >> N;
return 0;
}
// プログラムの実行: Ctrl + F5 または [デバッグ] > [デバッグなしで開始] メニュー
// プログラムのデバッグ: F5 または [デバッグ] > [デバッグの開始] メニュー
// 作業を開始するためのヒント:
// 1. ソリューション エクスプローラー
// ウィンドウを使用してファイルを追加/管理します
// 2. チーム エクスプローラー ウィンドウを使用してソース管理に接続します
// 3. 出力ウィンドウを使用して、ビルド出力とその他のメッセージを表示します
// 4. エラー一覧ウィンドウを使用してエラーを表示します
// 5. [プロジェクト] > [新しい項目の追加] と移動して新しいコード
// ファイルを作成するか、[プロジェクト] > [既存の項目の追加]
// と移動して既存のコード ファイルをプロジェクトに追加します
// 6. 後ほどこのプロジェクトを再び開く場合、[ファイル] > [開く] >
// [プロジェクト] と移動して .sln ファイルを選択します
| replace | 95 | 96 | 95 | 96 | TLE | |
p03196 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, p, ans = 1;
scanf("%lld%lld", &n, &p);
if (n == 1)
printf("%lld\n", p);
else {
for (int i = 2; i * i <= p; i += 2) {
int j = 0;
for (; p % i == 0; p /= i, j++)
;
for (int k = 0; k < (j / n); k++)
ans *= i;
if (i == 2)
i--;
}
printf("%lld\n", ans);
}
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
long long n, p, ans = 1;
scanf("%lld%lld", &n, &p);
if (n == 1)
printf("%lld\n", p);
else {
for (long long i = 2; i * i <= p; i += 2) {
int j = 0;
for (; p % i == 0; p /= i, j++)
;
for (int k = 0; k < (j / n); k++)
ans *= i;
if (i == 2)
i--;
}
printf("%lld\n", ans);
}
}
| replace | 9 | 10 | 9 | 10 | TLE | |
p03196 | C++ | Time Limit Exceeded | // #include <bits/stdc++.h>
// #include <stdio.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <fstream>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string.h>
#include <string>
#include <utility>
#include <vector>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000 // 2000000000
#define LLINF 1000000000000000000 // 9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000
using namespace std;
typedef long long int ll;
typedef pair<long long int, long long int> P;
int dy[5] = {0, 0, 1, -1, 0};
int dx[5] = {1, -1, 0, 0, 0};
bool isprime(long long int x) { // 与えられた整数が素数ならtrueを返す
if (x == 2) {
return true;
}
if (x < 2 || x % 2 == 0) {
return false;
}
long long int i = 3;
for (i; i <= sqrt(x); i += 2) {
if (x % i == 0) {
return false;
}
}
return true;
}
int main(void) {
long long int n, p;
long long int maxi = 1;
long long int i = 2;
cin >> n >> p;
if (i == 1) {
maxi = p;
} else {
while (p != 1) {
while (isprime(i) == false) {
i++;
}
if ((long long int)(pow(i, n)) < 0) {
// cout << "a " << i << endl;
break;
}
if (p < (long long int)(pow(i, n))) {
// cout << "b " << i << endl;
break;
}
while (1) {
if (p % (long long int)(pow(i, n)) == 0) {
// cout << "c " << i << endl;
p /= (long long int)(pow(i, n));
maxi *= i;
} else {
break;
}
}
i++;
}
}
cout << maxi << endl;
return 0;
} | // #include <bits/stdc++.h>
// #include <stdio.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <fstream>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string.h>
#include <string>
#include <utility>
#include <vector>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)
#define LFOR(i, a, b) for (long long int i = (a); i <= (b); i++)
#define LRFOR(i, a, b) for (long long int i = (a); i >= (b); i--)
#define MOD 1000000007
#define INF 1000000000 // 2000000000
#define LLINF 1000000000000000000 // 9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000
using namespace std;
typedef long long int ll;
typedef pair<long long int, long long int> P;
int dy[5] = {0, 0, 1, -1, 0};
int dx[5] = {1, -1, 0, 0, 0};
bool isprime(long long int x) { // 与えられた整数が素数ならtrueを返す
if (x == 2) {
return true;
}
if (x < 2 || x % 2 == 0) {
return false;
}
long long int i = 3;
for (i; i <= sqrt(x); i += 2) {
if (x % i == 0) {
return false;
}
}
return true;
}
int main(void) {
long long int n, p;
long long int maxi = 1;
long long int i = 2;
cin >> n >> p;
if (n == 1) {
maxi = p;
} else {
while (p != 1) {
while (isprime(i) == false) {
i++;
}
if ((long long int)(pow(i, n)) < 0) {
// cout << "a " << i << endl;
break;
}
if (p < (long long int)(pow(i, n))) {
// cout << "b " << i << endl;
break;
}
while (1) {
if (p % (long long int)(pow(i, n)) == 0) {
// cout << "c " << i << endl;
p /= (long long int)(pow(i, n));
maxi *= i;
} else {
break;
}
}
i++;
}
}
cout << maxi << endl;
return 0;
} | replace | 60 | 61 | 60 | 61 | TLE | |
p03196 | C++ | Runtime Error | #include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(a, b) for (int a = 0; a < (b); ++a)
#define REP1(i, n) for (int i = 1; i <= (n); ++i)
#define debug(x) cerr << #x << ": " << x << '\n'
#define all(x) (x).begin(), (x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n", (x) ? "Yes" : "No")
#define isPossible(x) printf("%s\n", (x) ? "Possible" : "Impossible")
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1 << 29)
// const long long INF = 1LL<<60;
#define Sp(p) cout << setprecision(25) << fixed << p << endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<ll>>
#define vs vector<string>
#define pii pair<int, int>
#define pis pair<int, string>
#define psi pair<string, int>
#define pll pair<ll, ll>
#define X first
#define Y second
#define pie 3.14159265358979323846
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
template <class T = int> T in() {
T x;
cin >> x;
return (x);
}
template <class T> void print(T &x) { cout << x << '\n'; }
const int MOD = (int)1e9 + 7;
const int mod = (int)998244353;
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
void COMint() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
ll COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll gcd(ll a, ll b) {
if (b == 0)
return a;
if (a > b) {
swap(a, b);
}
return gcd(a, b % a);
}
ll lcm(ll a, ll b) {
ll g;
g = gcd(a, b);
return b / g * a;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
if (a.second != b.second) {
return a.second < b.second;
} else {
return a.first < b.first;
}
}
bool compare_by_a(pair<int, int> a, pair<int, int> b) {
if (a.first != b.first) {
return a.first < b.first;
} else {
return a.second < b.second;
}
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
ll RS(ll N, ll P) {
if (P == 0) {
return 1;
} else {
if (P % 2 == 0) {
ll t = RS(N, P / 2);
return t * t;
} else {
return N * RS(N, P - 1);
}
}
}
bool greater_pair(pair<ll, ll> a, pair<ll, ll> b) {
if (a.first != b.first) {
return a.first > b.first;
} else {
return a.second > b.second;
}
}
struct mint {
ll x; // typedef long long ll;
mint(ll x = 0) : x((x % mod + mod) % mod) {}
mint &operator+=(const mint a) {
if ((x += a.x) >= mod)
x -= mod;
return *this;
}
mint &operator-=(const mint a) {
if ((x += mod - a.x) >= mod)
x -= mod;
return *this;
}
mint &operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res += a;
}
mint operator-(const mint a) const {
mint res(*this);
return res -= a;
}
mint operator*(const mint a) const {
mint res(*this);
return res *= a;
}
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
// for prime mod
mint inv() const { return pow(mod - 2); }
mint &operator/=(const mint a) { return (*this) *= a.inv(); }
mint operator/(const mint a) const {
mint res(*this);
return res /= a;
}
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }
struct combination {
vector<mint> fact, ifact;
combination(int n) : fact(n + 1), ifact(n + 1) {
assert(n < mod);
fact[0] = 1;
for (int i = 1; i <= n; ++i)
fact[i] = fact[i - 1] * i;
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i)
ifact[i - 1] = ifact[i] * i;
}
mint operator()(int n, int k) {
if (k < 0 || k > n)
return 0;
return fact[n] * ifact[k] * ifact[n - k];
}
} c(2000005);
string func(string S) {
if (S.length() < 1) {
return "";
} else {
return S.substr(1);
}
}
int main() {
ios::sync_with_stdio(false);
ll N, P;
cin >> N >> P;
ll ans = 1;
if (N == 1) {
cout << P << endl;
} else if (N > 40) {
cout << 1 << endl;
} else {
for (int i = 2; i <= sqrt(P); ++i) {
ll p = RS(i, N);
// ll p=pow(i,N);
while (P % p == 0) {
P /= p;
ans *= i;
}
}
cout << ans << endl;
}
return 0;
}
| #include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(a, b) for (int a = 0; a < (b); ++a)
#define REP1(i, n) for (int i = 1; i <= (n); ++i)
#define debug(x) cerr << #x << ": " << x << '\n'
#define all(x) (x).begin(), (x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define isYES(x) printf("%s\n", (x) ? "YES" : "NO")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define isYes(x) printf("%s\n", (x) ? "Yes" : "No")
#define isPossible(x) printf("%s\n", (x) ? "Possible" : "Impossible")
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair
#define INF (1 << 29)
// const long long INF = 1LL<<60;
#define Sp(p) cout << setprecision(25) << fixed << p << endl
#define vi vector<int>
#define vl vector<ll>
#define vii vector<vector<int>>
#define vll vector<vector<ll>>
#define vs vector<string>
#define pii pair<int, int>
#define pis pair<int, string>
#define psi pair<string, int>
#define pll pair<ll, ll>
#define X first
#define Y second
#define pie 3.14159265358979323846
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;
template <class T = int> T in() {
T x;
cin >> x;
return (x);
}
template <class T> void print(T &x) { cout << x << '\n'; }
const int MOD = (int)1e9 + 7;
const int mod = (int)998244353;
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
void COMint() {
fac[0] = fac[1] = 1;
finv[0] = finv[1] = 1;
inv[1] = 1;
for (int i = 2; i < MAX; i++) {
fac[i] = fac[i - 1] * i % MOD;
inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
finv[i] = finv[i - 1] * inv[i] % MOD;
}
}
ll COM(int n, int k) {
if (n < k)
return 0;
if (n < 0 || k < 0)
return 0;
return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll gcd(ll a, ll b) {
if (b == 0)
return a;
if (a > b) {
swap(a, b);
}
return gcd(a, b % a);
}
ll lcm(ll a, ll b) {
ll g;
g = gcd(a, b);
return b / g * a;
}
bool compare_by_b(pair<int, int> a, pair<int, int> b) {
if (a.second != b.second) {
return a.second < b.second;
} else {
return a.first < b.first;
}
}
bool compare_by_a(pair<int, int> a, pair<int, int> b) {
if (a.first != b.first) {
return a.first < b.first;
} else {
return a.second < b.second;
}
}
template <class T> inline bool chmin(T &a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template <class T> inline bool chmax(T &a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
ll RS(ll N, ll P) {
if (P == 0) {
return 1;
} else {
if (P % 2 == 0) {
ll t = RS(N, P / 2);
return t * t;
} else {
return N * RS(N, P - 1);
}
}
}
bool greater_pair(pair<ll, ll> a, pair<ll, ll> b) {
if (a.first != b.first) {
return a.first > b.first;
} else {
return a.second > b.second;
}
}
struct mint {
ll x; // typedef long long ll;
mint(ll x = 0) : x((x % mod + mod) % mod) {}
mint &operator+=(const mint a) {
if ((x += a.x) >= mod)
x -= mod;
return *this;
}
mint &operator-=(const mint a) {
if ((x += mod - a.x) >= mod)
x -= mod;
return *this;
}
mint &operator*=(const mint a) {
(x *= a.x) %= mod;
return *this;
}
mint operator+(const mint a) const {
mint res(*this);
return res += a;
}
mint operator-(const mint a) const {
mint res(*this);
return res -= a;
}
mint operator*(const mint a) const {
mint res(*this);
return res *= a;
}
mint pow(ll t) const {
if (!t)
return 1;
mint a = pow(t >> 1);
a *= a;
if (t & 1)
a *= *this;
return a;
}
// for prime mod
mint inv() const { return pow(mod - 2); }
mint &operator/=(const mint a) { return (*this) *= a.inv(); }
mint operator/(const mint a) const {
mint res(*this);
return res /= a;
}
};
istream &operator>>(istream &is, const mint &a) { return is >> a.x; }
ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }
struct combination {
vector<mint> fact, ifact;
combination(int n) : fact(n + 1), ifact(n + 1) {
assert(n < mod);
fact[0] = 1;
for (int i = 1; i <= n; ++i)
fact[i] = fact[i - 1] * i;
ifact[n] = fact[n].inv();
for (int i = n; i >= 1; --i)
ifact[i - 1] = ifact[i] * i;
}
mint operator()(int n, int k) {
if (k < 0 || k > n)
return 0;
return fact[n] * ifact[k] * ifact[n - k];
}
} c(2000005);
string func(string S) {
if (S.length() < 1) {
return "";
} else {
return S.substr(1);
}
}
int main() {
ios::sync_with_stdio(false);
ll N, P;
cin >> N >> P;
ll ans = 1;
if (N == 1) {
cout << P << endl;
} else if (N > 40) {
cout << 1 << endl;
} else {
for (int i = 2; i <= sqrt(P); ++i) {
ll p = RS(i, N);
if (p > P)
break;
// ll p=pow(i,N);
while (P % p == 0) {
P /= p;
ans *= i;
}
}
cout << ans << endl;
}
return 0;
} | insert | 218 | 218 | 218 | 220 | 0 | |
p03196 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u> bool chmax(t &a, u b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class t, class u> bool chmin(t &a, u b) {
if (b < a) {
a = b;
return true;
}
return false;
}
ll mod = 1000000007;
ll mypow(ll a, ll b) {
if (b == 1) {
return a;
} else {
return a * mypow(a, b - 1);
}
}
signed main() {
ll n, p;
cin >> n >> p;
map<ll, ll> m;
for (int i = 2; i * i <= p; i++) {
while (p % i == 0) {
m[i]++;
p /= i;
}
}
if (p != 1) {
m[p]++;
}
ll ans = 1;
for (auto &i : m) {
if (i.second >= n) {
ans *= mypow(i.first, i.second / n);
}
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#define vi vector<int>
template <class t, class u> bool chmax(t &a, u b) {
if (a < b) {
a = b;
return true;
}
return false;
}
template <class t, class u> bool chmin(t &a, u b) {
if (b < a) {
a = b;
return true;
}
return false;
}
ll mod = 1000000007;
ll mypow(ll a, ll b) {
if (b == 1) {
return a;
} else {
return a * mypow(a, b - 1);
}
}
signed main() {
ll n, p;
cin >> n >> p;
map<ll, ll> m;
for (ll i = 2; i * i <= p; i++) {
while (p % i == 0) {
m[i]++;
p /= i;
}
}
if (p != 1) {
m[p]++;
}
ll ans = 1;
for (auto &i : m) {
if (i.second >= n) {
ans *= mypow(i.first, i.second / n);
}
}
cout << ans << endl;
return 0;
} | replace | 40 | 41 | 40 | 41 | TLE | |
p03196 | C++ | Time Limit Exceeded | #include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
long long n, p, ans;
int main() {
scanf("%lld%lld", &n, &p);
long long ans = 1;
for (int i = 2; i * i <= p; i++) {
int tot = 0;
while (p % i == 0) {
tot++;
if (tot == n)
tot = 0, ans *= i;
p /= i;
}
}
if (n == 1)
ans *= p;
printf("%lld\n", ans);
} | #include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
long long n, p, ans;
int main() {
scanf("%lld%lld", &n, &p);
long long ans = 1;
for (long long i = 2; i * i <= p; i++) {
int tot = 0;
while (p % i == 0) {
tot++;
if (tot == n)
tot = 0, ans *= i;
p /= i;
}
}
if (n == 1)
ans *= p;
printf("%lld\n", ans);
} | replace | 8 | 9 | 8 | 9 | TLE | |
p03196 | C++ | Time Limit Exceeded | #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize(3)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target("sse3", "sse2", "sse")
#pragma GCC target("avx", "sse4", "sse4.1", "sse4.2", "ssse3")
#pragma GCC target("f16c")
#pragma GCC optimize("inline", "fast-math", "unroll-loops", \
"no-stack-protector")
#pragma GCC diagnostic error "-fwhole-program"
#pragma GCC diagnostic error "-fcse-skip-blocks"
#pragma GCC diagnostic error "-funsafe-loop-optimizations"
#pragma GCC diagnostic error "-std=c++14"
#include "bits/stdc++.h"
// #include "ext/pb_ds/tree_policy.hpp"
// #include "ext/pb_ds/assoc_container.hpp"
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x, "r", stdin)
#define fw(x) freopen(x, "w", stdout)
#define iout(x) printf("%d\n", x)
#define lout(x) printf("%lld\n", x)
#define REP(x, l, u) for (ll x = l; x < u; x++)
#define RREP(x, l, u) for (ll x = l; x >= u; x--)
#define complete_unique(a) a.erase(unique(a.begin(), a.end()), a.end())
#define mst(x, a) memset(x, a, sizeof(x))
#define all(a) a.begin(), a.end()
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define MP make_pair
#define sqr(x) ((x) * (x))
#define lowbit(x) ((x) & (-(x)))
#define lson (ind << 1)
#define rson (ind << 1 | 1)
#define se second
#define fi first
#define dbg(x) cerr << #x << " = " << (x) << endl;
#define sz(x) ((int)x.size())
#define EX0 exit(0);
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;
typedef vector<ll> VLL;
typedef vector<int> VI;
const int block_size = 320;
typedef complex<ll> point;
const ll mod = 1e9 + 7;
const ll inf = 1e9 + 7;
const ld eps = 1e-9;
const db PI = atan(1) * 4;
template <typename T> inline int sign(const T &a) {
if (a < 0)
return -1;
if (a > 0)
return 1;
return 0;
}
template <typename T, typename S> inline bool upmin(T &a, const S &b) {
return a > b ? a = b, 1 : 0;
}
template <typename T, typename S> inline bool upmax(T &a, const S &b) {
return a < b ? a = b, 1 : 0;
}
template <typename T> inline void in(T &x) {
x = 0;
T f = 1;
char ch = getchar();
while (!isdigit(ch)) {
if (ch == '-')
f = -1;
ch = getchar();
}
while (isdigit(ch)) {
x = x * 10 + ch - '0';
ch = getchar();
}
x *= f;
}
ll twop(int x) { return 1LL << x; }
template <typename A, typename B> inline void in(A &x, B &y) {
in(x);
in(y);
}
template <typename A, typename B, typename C> inline void in(A &x, B &y, C &z) {
in(x);
in(y);
in(z);
}
template <typename A, typename B, typename C, typename D>
inline void in(A &x, B &y, C &z, D &d) {
in(x);
in(y);
in(z);
in(d);
}
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
namespace SOLVE {
void main() {
ll n, p;
in(n, p);
map<ll, ll> cnt;
REP(i, 2, 1000010) {
if (p % i == 0) {
while (p % i == 0) {
cnt[i]++;
p /= i;
}
}
if (i > p)
break;
}
if (p > 1)
cnt[p]++;
ll ans = 1;
for (auto i : cnt) {
while (i.se >= n) {
ans *= i.fi;
i.se -= n;
}
}
cout << ans << endl;
}
} // namespace SOLVE
signed main() {
#ifndef ONLINE_JUDGE
fr("/Users/zhangqingchuan/Desktop/cp/cp/input.txt");
fw("/Users/zhangqingchuan/Desktop/cp/cp/output.txt");
#endif
int t;
t = 1;
// return 0;
while (t--) {
SOLVE::main();
}
return 0;
}
| #pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC optimize(3)
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target("sse3", "sse2", "sse")
#pragma GCC target("avx", "sse4", "sse4.1", "sse4.2", "ssse3")
#pragma GCC target("f16c")
#pragma GCC optimize("inline", "fast-math", "unroll-loops", \
"no-stack-protector")
#pragma GCC diagnostic error "-fwhole-program"
#pragma GCC diagnostic error "-fcse-skip-blocks"
#pragma GCC diagnostic error "-funsafe-loop-optimizations"
#pragma GCC diagnostic error "-std=c++14"
#include "bits/stdc++.h"
// #include "ext/pb_ds/tree_policy.hpp"
// #include "ext/pb_ds/assoc_container.hpp"
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x, "r", stdin)
#define fw(x) freopen(x, "w", stdout)
#define iout(x) printf("%d\n", x)
#define lout(x) printf("%lld\n", x)
#define REP(x, l, u) for (ll x = l; x < u; x++)
#define RREP(x, l, u) for (ll x = l; x >= u; x--)
#define complete_unique(a) a.erase(unique(a.begin(), a.end()), a.end())
#define mst(x, a) memset(x, a, sizeof(x))
#define all(a) a.begin(), a.end()
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define MP make_pair
#define sqr(x) ((x) * (x))
#define lowbit(x) ((x) & (-(x)))
#define lson (ind << 1)
#define rson (ind << 1 | 1)
#define se second
#define fi first
#define dbg(x) cerr << #x << " = " << (x) << endl;
#define sz(x) ((int)x.size())
#define EX0 exit(0);
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;
typedef vector<ll> VLL;
typedef vector<int> VI;
const int block_size = 320;
typedef complex<ll> point;
const ll mod = 1e9 + 7;
const ll inf = 1e9 + 7;
const ld eps = 1e-9;
const db PI = atan(1) * 4;
template <typename T> inline int sign(const T &a) {
if (a < 0)
return -1;
if (a > 0)
return 1;
return 0;
}
template <typename T, typename S> inline bool upmin(T &a, const S &b) {
return a > b ? a = b, 1 : 0;
}
template <typename T, typename S> inline bool upmax(T &a, const S &b) {
return a < b ? a = b, 1 : 0;
}
template <typename T> inline void in(T &x) {
x = 0;
T f = 1;
char ch = getchar();
while (!isdigit(ch)) {
if (ch == '-')
f = -1;
ch = getchar();
}
while (isdigit(ch)) {
x = x * 10 + ch - '0';
ch = getchar();
}
x *= f;
}
ll twop(int x) { return 1LL << x; }
template <typename A, typename B> inline void in(A &x, B &y) {
in(x);
in(y);
}
template <typename A, typename B, typename C> inline void in(A &x, B &y, C &z) {
in(x);
in(y);
in(z);
}
template <typename A, typename B, typename C, typename D>
inline void in(A &x, B &y, C &z, D &d) {
in(x);
in(y);
in(z);
in(d);
}
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
namespace SOLVE {
void main() {
ll n, p;
in(n, p);
map<ll, ll> cnt;
REP(i, 2, 1000010) {
if (p % i == 0) {
while (p % i == 0) {
cnt[i]++;
p /= i;
}
}
if (i > p)
break;
}
if (p > 1)
cnt[p]++;
ll ans = 1;
for (auto i : cnt) {
while (i.se >= n) {
ans *= i.fi;
i.se -= n;
}
}
cout << ans << endl;
}
} // namespace SOLVE
signed main() {
// #ifndef ONLINE_JUDGE
// fr("/Users/zhangqingchuan/Desktop/cp/cp/input.txt");
// fw("/Users/zhangqingchuan/Desktop/cp/cp/output.txt");
// #endif
int t;
t = 1;
// return 0;
while (t--) {
SOLVE::main();
}
return 0;
}
| replace | 134 | 138 | 134 | 138 | TLE | |
p03196 | C++ | Runtime Error | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll n, p;
cin >> n >> p;
vector<ll> num(1001000, 0);
if (n == 1) {
cout << p << endl;
return 0;
}
if (p == 1) {
cout << 1 << endl;
return 0;
}
ll ans = 1;
if (p % 2 == 0) {
while (p % 2 == 0) {
p /= 2;
num[2]++;
}
if (num[2] / n > 0)
ans *= pow(2, num[2] / n);
}
for (int i = 3; i * i <= p; i += 2) {
ll x = ll(i);
while (p % x == 0) {
p /= x;
num[i]++;
}
if (num[i] / n > 0)
ans *= pow(x, num[i] / n);
}
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
ll n, p;
cin >> n >> p;
vector<ll> num(1001000, 0);
if (n == 1) {
cout << p << endl;
return 0;
}
if (p == 1) {
cout << 1 << endl;
return 0;
}
ll ans = 1;
if (p % 2 == 0) {
while (p % 2 == 0) {
p /= 2;
num[2]++;
}
if (num[2] / n > 0)
ans *= pow(2, num[2] / n);
}
for (ll x = 3; x * x <= p; x += 2) {
int i = int(x);
while (p % x == 0) {
p /= x;
num[i]++;
}
if (num[i] / n > 0)
ans *= pow(x, num[i] / n);
}
cout << ans << endl;
} | replace | 25 | 27 | 25 | 27 | 0 | |
p03196 | C++ | Time Limit Exceeded | #include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;
inline char gc() {
// static char buf[100000],*p1,*p2;
// return
//p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin)),p1==p2)?EOF:*p1++;
return getchar();
}
template <class T> int read(T &ans) {
ans = 0;
T f = 1;
char ch = gc();
while (!isdigit(ch)) {
if (ch == '-')
f = -1;
if (ch == EOF)
return EOF;
ch = gc();
}
while (isdigit(ch))
ans = ans * 10 + ch - '0', ch = gc();
ans *= f;
return 1;
}
typedef long long ll;
int main() {
// freopen("test.in","r",stdin);
ll n, p, ans = 1;
read(n);
read(p);
for (int i = 2; i * i <= p; i++) {
ll temp = 0;
while (p % i == 0)
p /= i, temp++;
temp /= n;
while (temp--)
ans *= i;
}
if (n == 1)
ans *= p;
printf("%lld\n", ans);
return 0;
}
| #include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;
inline char gc() {
// static char buf[100000],*p1,*p2;
// return
//p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin)),p1==p2)?EOF:*p1++;
return getchar();
}
template <class T> int read(T &ans) {
ans = 0;
T f = 1;
char ch = gc();
while (!isdigit(ch)) {
if (ch == '-')
f = -1;
if (ch == EOF)
return EOF;
ch = gc();
}
while (isdigit(ch))
ans = ans * 10 + ch - '0', ch = gc();
ans *= f;
return 1;
}
typedef long long ll;
int main() {
// freopen("test.in","r",stdin);
ll n, p, ans = 1;
read(n);
read(p);
for (ll i = 2; i * i <= p; i++) {
ll temp = 0;
while (p % i == 0)
p /= i, temp++;
temp /= n;
while (temp--)
ans *= i;
}
if (n == 1)
ans *= p;
printf("%lld\n", ans);
return 0;
}
| replace | 38 | 39 | 38 | 39 | TLE | |
p03196 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(i) i.begin(), i.end()
template <class T, class U> bool cmax(T &a, U b) {
if (a < b) {
a = b;
return true;
} else
return false;
}
template <class T, class U> bool cmin(T &a, U b) {
if (a > b) {
a = b;
return true;
} else
return false;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll n, p;
cin >> n >> p;
ll ans = 1;
for (int i = 2; i * i <= p; i++) {
int cnt = 0;
while (p % i == 0) {
p /= i;
cnt++;
}
// ans *= pow(i, cnt/n);
rep(j, cnt / n) { ans *= i; }
}
ans *= pow(p, 1 / n);
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(i) i.begin(), i.end()
template <class T, class U> bool cmax(T &a, U b) {
if (a < b) {
a = b;
return true;
} else
return false;
}
template <class T, class U> bool cmin(T &a, U b) {
if (a > b) {
a = b;
return true;
} else
return false;
}
int main() {
cin.tie(0);
ios::sync_with_stdio(false);
ll n, p;
cin >> n >> p;
ll ans = 1;
for (ll i = 2; i * i <= p; i++) {
int cnt = 0;
while (p % i == 0) {
p /= i;
cnt++;
}
// ans *= pow(i, cnt/n);
rep(j, cnt / n) { ans *= i; }
}
ans *= pow(p, 1 / n);
cout << ans << endl;
}
| replace | 31 | 32 | 31 | 32 | TLE | |
p03196 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
#define int long long
map<int, int> prime_factor(int n) {
map<int, int> ret;
for (int i = 2; i * i <= n; i++) {
while (n % i == 0) {
ret[i]++;
n /= i;
}
}
if (n != 1)
ret[n] = 1;
return ret;
}
signed main() {
cin.tie(0);
ios_base::sync_with_stdio(0);
cout << fixed << setprecision(12);
int n, p;
cin >> n >> p;
if (n == 1) {
cout << p << endl;
return 0;
}
for (int i = sqrt(p); i >= 1; i--) {
if (p % i)
continue;
bool f = true;
int q = 1;
for (int j = 0; j < n; j++) {
q *= i;
if (q > p) {
f = false;
break;
}
}
if (f && p % q == 0) {
cout << i << endl;
return 0;
}
}
cout << 1 << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
#define int long long
map<int, int> prime_factor(int n) {
map<int, int> ret;
for (int i = 2; i * i <= n; i++) {
while (n % i == 0) {
ret[i]++;
n /= i;
}
}
if (n != 1)
ret[n] = 1;
return ret;
}
signed main() {
cin.tie(0);
ios_base::sync_with_stdio(0);
cout << fixed << setprecision(12);
int n, p;
cin >> n >> p;
if (n == 1) {
cout << p << endl;
return 0;
}
for (int i = sqrt(p); i >= 2; i--) {
if (p % i)
continue;
bool f = true;
int q = 1;
for (int j = 0; j < n; j++) {
q *= i;
if (q > p) {
f = false;
break;
}
}
if (f && p % q == 0) {
cout << i << endl;
return 0;
}
}
cout << 1 << endl;
return 0;
}
| replace | 30 | 31 | 30 | 32 | TLE | |
p03196 | C++ | Time Limit Exceeded | #include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";
using namespace std;
template <typename T>
std::ostream &operator<<(std::ostream &out, vector<T> &v) {
for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
out << v[i] << " ";
out << "\n";
return out;
}
template <typename T, typename N>
std::ostream &operator<<(std::ostream &out, vector<pair<T, N>> &v) {
for (size_t i = 0; i < v.size(); ++i)
out << "(" << v[i].first << ", " << v[i].second << ") ";
out << "\n";
return out;
}
template <typename T>
std::ostream &operator<<(std::ostream &out, vector<vector<T>> &v) {
for (size_t i = 0; i < v.size(); ++i) {
for (size_t j = 0; j < v[i].size(); ++j) {
out << v[i][j] << " ";
}
out << "\n";
}
return out;
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long n, p;
cin >> n >> p;
map<long long, int> factors;
while (p % 2 == 0) {
++factors[2];
p >>= 1;
}
for (int i = 3; i * i <= p; i += 2) {
while (p % i == 0) {
++factors[i];
p /= i;
}
}
if (p > 2) {
++factors[p];
}
long long g = 1;
for (auto it = factors.begin(); it != factors.end(); ++it) {
g *= pow(it->first, (it->second) / n);
}
cout << g << "\n";
return 0;
} | #include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";
using namespace std;
template <typename T>
std::ostream &operator<<(std::ostream &out, vector<T> &v) {
for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
out << v[i] << " ";
out << "\n";
return out;
}
template <typename T, typename N>
std::ostream &operator<<(std::ostream &out, vector<pair<T, N>> &v) {
for (size_t i = 0; i < v.size(); ++i)
out << "(" << v[i].first << ", " << v[i].second << ") ";
out << "\n";
return out;
}
template <typename T>
std::ostream &operator<<(std::ostream &out, vector<vector<T>> &v) {
for (size_t i = 0; i < v.size(); ++i) {
for (size_t j = 0; j < v[i].size(); ++j) {
out << v[i][j] << " ";
}
out << "\n";
}
return out;
}
int main() {
std::ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
long long n, p;
cin >> n >> p;
map<long long, int> factors;
while (p % 2 == 0) {
++factors[2];
p >>= 1;
}
for (long long i = 3; i * i <= p; i += 2) {
while (p % i == 0) {
++factors[i];
p /= i;
}
}
if (p > 2) {
++factors[p];
}
long long g = 1;
for (auto it = factors.begin(); it != factors.end(); ++it) {
g *= pow(it->first, (it->second) / n);
}
cout << g << "\n";
return 0;
} | replace | 63 | 64 | 63 | 64 | TLE | |
p03196 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main() {
long long N, P;
cin >> N >> P;
long long ans = 1;
for (int i = 2; i * i <= P; i++) {
if (P % i == 0) {
int cnt = 0;
while (P % i == 0) {
P /= i;
cnt++;
}
for (int j = 0; j < cnt / N; j++) {
ans *= i;
}
}
}
if (N == 1) {
ans *= P;
}
cout << ans << endl;
} | #include <bits/stdc++.h>
using namespace std;
int main() {
long long N, P;
cin >> N >> P;
long long ans = 1;
for (long long i = 2; i * i <= P; i++) {
if (P % i == 0) {
int cnt = 0;
while (P % i == 0) {
P /= i;
cnt++;
}
for (int j = 0; j < cnt / N; j++) {
ans *= i;
}
}
}
if (N == 1) {
ans *= P;
}
cout << ans << endl;
} | replace | 6 | 7 | 6 | 7 | TLE | |
p03196 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<ll, ll> p;
ll Mod = 1000000007;
vector<p> pri(ll n) {
vector<p> Pr;
for (int i = 2; i * i <= n; i++) {
int cnt = 0;
while (n % i == 0) {
cnt++;
n /= i;
}
if (cnt != 0) {
Pr.push_back(make_pair(i, cnt));
}
}
if (n != 1)
Pr.push_back(make_pair(n, 1LL));
return Pr;
}
int main() {
ll N, P;
cin >> N >> P;
vector<p> S = pri(P);
ll ans = 1;
for (int i = 0; i < S.size(); i++) {
for (int j = 0; j < S[i].second / N; j++) {
ans *= S[i].first;
}
}
cout << ans << endl;
return 0;
} | #include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<ll, ll> p;
ll Mod = 1000000007;
vector<p> pri(ll n) {
vector<p> Pr;
for (ll i = 2; i * i <= n; i++) {
int cnt = 0;
while (n % i == 0) {
cnt++;
n /= i;
}
if (cnt != 0) {
Pr.push_back(make_pair(i, cnt));
}
}
if (n != 1)
Pr.push_back(make_pair(n, 1LL));
return Pr;
}
int main() {
ll N, P;
cin >> N >> P;
vector<p> S = pri(P);
ll ans = 1;
for (int i = 0; i < S.size(); i++) {
for (int j = 0; j < S[i].second / N; j++) {
ans *= S[i].first;
}
}
cout << ans << endl;
return 0;
}
| replace | 8 | 9 | 8 | 9 | TLE | |
p03196 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
int main() {
int64_t N, P;
cin >> N >> P;
map<int64_t, int64_t> M;
int64_t X = P;
for (int i = 2; i * i <= P && i <= X; i++) {
if (X % i == 0) {
int64_t a = 0;
while (X % i == 0) {
X /= i;
a++;
}
a /= N;
M[i] = a;
}
}
if (X != 1)
M[X] = (1 / N);
int64_t ans = 1;
for (auto p : M) {
auto k = p.first;
auto v = p.second;
ans *= powl(k, v);
}
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
using namespace std;
int main() {
int64_t N, P;
cin >> N >> P;
map<int64_t, int64_t> M;
int64_t X = P;
for (int64_t i = 2; i * i <= P && i <= X; i++) {
if (X % i == 0) {
int64_t a = 0;
while (X % i == 0) {
X /= i;
a++;
}
a /= N;
M[i] = a;
}
}
if (X != 1)
M[X] = (1 / N);
int64_t ans = 1;
for (auto p : M) {
auto k = p.first;
auto v = p.second;
ans *= powl(k, v);
}
cout << ans << endl;
return 0;
}
| replace | 7 | 8 | 7 | 8 | TLE | |
p03196 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
// cd test ; rm -R ./*; cd ..
int main(void) {
ll n, p;
cin >> n >> p;
ll ans = 1;
if (n == 1) {
cout << p << endl;
return 0;
}
for (int i = 2; i * i <= p; i++) {
ll cnt = 0;
while (p % i == 0) {
cnt++;
p /= i;
}
if (cnt >= n) {
ans *= (ll)pow(i, cnt / n);
}
}
cout << ans << endl;
return 0;
}
| #include <bits/stdc++.h>
#define rep(i, n) for (int(i) = 0; (i) < (n); (i)++)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
// cd test ; rm -R ./*; cd ..
int main(void) {
ll n, p;
cin >> n >> p;
ll ans = 1;
if (n == 1) {
cout << p << endl;
return 0;
}
for (ll i = 2; i * i <= p; i++) {
ll cnt = 0;
while (p % i == 0) {
cnt++;
p /= i;
}
if (cnt >= n) {
ans *= (ll)pow(i, cnt / n);
}
}
cout << ans << endl;
return 0;
}
| replace | 18 | 19 | 18 | 19 | TLE | |
p03196 | C++ | Runtime Error | #include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <stack>
using namespace std;
long long mpow(long long a, long long b) {
long long cur = a;
long long ans = 1;
for (;;) {
if (b == 0)
return ans;
if (b & 1) {
ans = ans * cur;
}
b = b >> 1;
cur = cur * cur;
}
}
int main() {
long long n, p;
cin >> n >> p;
if (n == 1) {
cout << p << endl;
return 0;
}
long long ans = 1;
long long arr[1000000];
int ind = 0;
long long cnt = 1;
for (long long a = 2; mpow(a, n) <= p; a = a + 1) {
cnt = a;
}
// cout<<cnt<<endl;
for (long long a = cnt; a >= 1; a--) {
if (p % mpow(a, n) == 0) {
cout << a << endl;
return 0;
}
}
return 0;
} | #include <algorithm>
#include <bits/stdc++.h>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <stack>
using namespace std;
long long mpow(long long a, long long b) {
long long cur = a;
long long ans = 1;
for (;;) {
if (b == 0)
return ans;
if (b & 1) {
ans = ans * cur;
}
b = b >> 1;
cur = cur * cur;
}
}
int main() {
long long n, p;
cin >> n >> p;
if (n == 1) {
cout << p << endl;
return 0;
}
if (n >= 40) {
cout << '1' << endl;
return 0;
}
long long ans = 1;
long long arr[1000000];
int ind = 0;
long long cnt = 1;
for (long long a = 2; mpow(a, n) <= p; a = a + 1) {
cnt = a;
}
// cout<<cnt<<endl;
for (long long a = cnt; a >= 1; a--) {
if (p % mpow(a, n) == 0) {
cout << a << endl;
return 0;
}
}
return 0;
} | insert | 29 | 29 | 29 | 33 | 0 | |
p03196 | C++ | Time Limit Exceeded | #include <cmath>
#include <iostream>
using namespace std;
typedef long long ll;
int main() {
ll n, m;
cin >> n >> m;
ll ans = 1;
if (n == 1) {
cout << m << endl;
} else {
for (int i = 2; i * i <= m; i++) {
int count = 0;
ll k = m;
while (k % i == 0 && count < n) {
k /= i;
count++;
}
if (count == n) {
ans = i;
}
}
cout << ans << endl;
}
}
| #include <cmath>
#include <iostream>
using namespace std;
typedef long long ll;
int main() {
ll n, m;
cin >> n >> m;
ll ans = 1;
if (n == 1) {
cout << m << endl;
} else {
for (ll i = 2; i * i <= m; i++) {
int count = 0;
ll k = m;
while (k % i == 0 && count < n) {
k /= i;
count++;
}
if (count == n) {
ans = i;
}
}
cout << ans << endl;
}
}
| replace | 13 | 14 | 13 | 14 | TLE | |
p03196 | C++ | Time Limit Exceeded | #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
long long MOD = 1000000000 + 7;
template <typename T> map<T, ll> prime_factorize(T x) {
map<T, ll> res;
for (int i = 2; i * i <= x; i++) {
while (x % i == 0) {
x /= i;
res[i]++;
}
}
if (x != 1)
res[x]++;
return res;
}
map<ll, ll> merge(map<ll, ll> m1, map<ll, ll> m2) {
map<ll, ll> m;
for (auto x : m1) {
if (m2.count(x.first) != 0) {
m[x.first] = min(m1[x.first], m2[x.first]);
}
}
return m;
}
ll mpow(ll x, ll n) {
if (n == 0)
return 1;
if (n % 2 == 0)
return mpow(x * x, n / 2);
else
return x * mpow(x, n - 1);
}
int main() {
cout << setprecision(10);
ll N, P;
cin >> N >> P;
map<ll, ll> m = prime_factorize(P);
ll ans = 1;
for (auto x : m) {
if (x.second >= N) {
ll pow_num = x.second / N;
ans *= mpow(x.first, pow_num);
}
}
cout << ans << endl;
}
| #include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
long long MOD = 1000000000 + 7;
template <typename T> map<T, ll> prime_factorize(T x) {
map<T, ll> res;
while (x % 2 == 0) {
x /= 2;
res[2]++;
}
for (ll i = 3; i * i <= x; i += 2) {
while (x % i == 0) {
x /= i;
res[i]++;
}
}
if (x != 1)
res[x]++;
return res;
}
map<ll, ll> merge(map<ll, ll> m1, map<ll, ll> m2) {
map<ll, ll> m;
for (auto x : m1) {
if (m2.count(x.first) != 0) {
m[x.first] = min(m1[x.first], m2[x.first]);
}
}
return m;
}
ll mpow(ll x, ll n) {
if (n == 0)
return 1;
if (n % 2 == 0)
return mpow(x * x, n / 2);
else
return x * mpow(x, n - 1);
}
int main() {
cout << setprecision(10);
ll N, P;
cin >> N >> P;
map<ll, ll> m = prime_factorize(P);
ll ans = 1;
for (auto x : m) {
if (x.second >= N) {
ll pow_num = x.second / N;
ans *= mpow(x.first, pow_num);
}
}
cout << ans << endl;
}
| replace | 10 | 11 | 10 | 17 | TLE |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.