我这种zz大概也就只能写个beginner级的题解吧
同样的预处理,然后枚举质因子,若该质因子p的次数大于等于n,就给答案乘p,次数-=n再判断,判断不成立在进行下一个
#include <bits/stdc++.h>
#define LL long long
#define int long long
#define db double
using namespace std;
const int MAXN = 500500;
const int MAXE = 400400;
const int INF = (1LL << 60 | 100);
template<typename T> inline void CheckMax(T &A, T B) {
A < B ? A = B : A;
}
template<typename T> inline void CheckMin(T &A, T B) {
A > B ? A = B : A;
}
template <typename T> inline void read(T &x) {
int c = getchar();
bool f = false;
for (x = 0; !isdigit(c); c = getchar()) {
if (c == '-') {
f = true;
}
}
for (; isdigit(c); c = getchar()) {
x = x * 10 + c - '0';
}
if (f) {
x = -x;
}
}
LL n, m;
LL P[MAXN], cnt, num[MAXN];
void solve(LL x) {
for(LL i = 2; i * i <= x; i++) {
if(x % i == 0) {
LL cur = 0;
while(x % i == 0) {
x /= i;
cur++;
}
P[++cnt] = cur;
num[cnt] = i;
}
}
if(x > 1) P[++cnt] = 1;
}
signed main() {
cin >> n >> m;
if(n == 1) {
cout << m << endl;
return 0;
}
if(n > m) {
cout << 1 << endl;
return 0;
}
solve(m);
LL ans = 1LL;
for(int i = 1; i <= cnt; i++) {
while(P[i] >= n) {
ans = ans * num[i], P[i] -= n;
}
}
cout << ans << endl;
return 0;
}
蜜汁博弈论……全是偶数后手必胜……完了
#include <bits/stdc++.h>
#define LL long long
#define db double
using namespace std;
const int MAXN = 500500;
const int MAXE = 400400;
const int INF = 0x7FFFFFFF;
template<typename T> inline void CheckMax(T &A, T B) {
A < B ? A = B : A;
}
template<typename T> inline void CheckMin(T &A, T B) {
A > B ? A = B : A;
}
template <typename T> inline void read(T &x) {
int c = getchar();
bool f = false;
for (x = 0; !isdigit(c); c = getchar()) {
if (c == '-') {
f = true;
}
}
for (; isdigit(c); c = getchar()) {
x = x * 10 + c - '0';
}
if (f) {
x = -x;
}
}
int n;
#define Fir puts("first")
#define Sec puts("second")
int a[MAXN], res;
signed main() {
read(n);
for(int i = 1; i <= n; i++) {
read(a[i]);
if(a[i] & 1) res = 1;
}
if(res) Fir;
else Sec;
return 0;
}