AcWing 867. 分解质因数
原题链接
简单
作者:
dark_7
,
2021-12-13 20:30:33
,
所有人可见
,
阅读 144
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <iomanip>
#include <sstream>
#include <vector>
//#include <list>
//#include <stack>
//#include <queue>
//#include <set>
//#include <map>
#define endl "\n"
using namespace std;
typedef long long LL;
typedef unsigned long long uLL;
int main() {
ios::sync_with_stdio(false);
cin.tie(0); cout.tie(0);
int t; cin >> t;
while (t--)
{
int a; cin >> a;
for (int i = 2;i <= a / i;i++)
{
if (a % i == 0)
{
int s = 0;
while (a % i == 0)
{
//cout << " a = " << a << " i = " << i << " s = " << s;
a /= i;
s++;
//cout << " a ====>> a/i = " << a << " s = " << s << endl;
}
cout << i << " " << s << endl;
//cout<< "答案: " << " 底数: " << i << " 指数: " << s << endl;
}
}
if (a > 1) cout << a << ' ' << 1 << endl;
//cout << "当 a > 1时" << endl << "答案: " << " 底数: " << a << " 指数: " << 1 << endl;
cout << endl;
}
return 0;
}