# 2946. 整数的质因子分解

// https://acm.ecnu.edu.cn/problem/2946/
#include <iostream>

using namespace std;

void getDivides(int n) {
for (int i = 2; i <= n / i; i ++) {
if (n % i == 0) {
int s = 0;
while (n % i == 0) {
n /= i;
s ++;
}
printf("(%d,%d)", i , s);
}
}

if (n > 1) printf("(%d,%d)", n , 1);
puts("");
}

int main() {
int T;
cin >> T;

while (T --) {
int n;
cin >> n;
getDivides(n);
}

return 0;
}

#include <iostream>
#include <vector>
using namespace std;

struct item
{
int p;
int e;
};

bool isPrime(int n)
{
if (n % 2 == 0)
return false;
for (int i = 3; i * i < n; ++i)
{
if (n % i == 0)
return false;
}
return true;
}

int main()
{
vector<int> Prime({ 2 });
for (int i = 3; i < 20000; ++i)
if (isPrime(i))
Prime.push_back(i);
int t;
cin >> t;
while (t--)
{
int a;
cin >> a;
vector<item> vec;
for (auto beg = Prime.begin(); beg != Prime.end(); beg++)
{
if (a % *beg == 0)
{
int cnt = 0;
while (a % *beg == 0)
{
++cnt;
a /= *beg;
}
vec.push_back({ *beg,cnt });
}
else if (a == *beg)
{
vec.push_back({ a, 1 });
break;
}
}
for (const auto &i : vec)
cout << '(' << i.p << "," << i.e << ')';
cout << endl;
}
return 0;
}


from math import sqrt
T=int(input())
for I in range(T):
n=int(input())
count=0
while n%2 == 0:
n//=2
count+=1
if count:
print("(2,%d)"%count, end="")
max=int(sqrt(n))+1
for i in range(3, max, 2):
count=0
while n%i==0:
n//=i
count+=1
if count:
print("(%d,%d)"%(i, count), end="")
if n!=1:
print("(%d,1)"%n, end="")
print()


for example:

from collections import Counter as C

for t in range(int(input())):
a, c = int(input()), C()
for i in range(2, int(a ** 0.5) + 1):
while a % i == 0:
a //= i
c[i] += 1
if a > 1:
c[a] += 1
print(''.join(f'({k},{v})' for k, v in c.items()))


### include

using namespace std;
int T,n;

void solve()
{
int N=n;
for(int i=2;i<=n;i++) //不要像我一样从1开始枚举，囧
{
int cnt=0;
if(N%i!=0) continue;
while(N%i==0)
{
N/=i;
cnt++;
}
printf(“(%d,%d)”,i,cnt);
if(N==1) break;
}
cout<>T;
for(int step=0;step>n;
solve();
}
}