/ SeriousOJ /

Record Detail

Accepted


  
# Status Time Cost Memory Cost
#1 Accepted 1ms 532.0 KiB
#2 Accepted 2ms 532.0 KiB
#3 Accepted 10ms 532.0 KiB
#4 Accepted 10ms 532.0 KiB
#5 Accepted 81ms 576.0 KiB
#6 Accepted 72ms 572.0 KiB
#7 Accepted 9ms 568.0 KiB
#8 Accepted 10ms 576.0 KiB
#9 Accepted 393ms 616.0 KiB
#10 Accepted 979ms 712.0 KiB
#11 Accepted 176ms 572.0 KiB
#12 Accepted 28ms 532.0 KiB

Code

#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 1000005;

int y, a, i, z;
VI v;
LL x;

int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);

cin >> z;
while(z--) {
	cin >> x >> y;
	v.clear();
	a = x;
	for (i=2;i*i<=a;i++) if (a % i == 0) {
		while (a % i == 0) {
			a /= i;
			v.pb(i);
		}
	}
	if (a > 1) v.pb(a);
	while (y > 0 && v[0] != v.back()) {
		x *= v[0];
		y--;
		//cout << " " << x << endl;
		if (y > 0) {
			x /= v.back();
			v.pop_back();
			y--;
		}
		//cout << x << endl;
	}
	if (y % 2 == 1) x *= v[0];
	cout << x << endl;
}
return 0;
}

Information

Submit By
Type
Submission
Problem
P1194 D. Roy and Prime Game
Contest
Happy New Year 2026
Language
C++17 (G++ 13.2.0)
Submit At
2026-01-06 15:07:04
Judged At
2026-01-06 15:07:05
Judged By
Score
100
Total Time
979ms
Peak Memory
712.0 KiB