mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-23 23:48:48 +00:00
867. 分解质因数
https://www.acwing.com/problem/content/submission/code_detail/7241866/
This commit is contained in:
parent
737db35706
commit
d71d5e8ad8
27
AcWing/867/867.cpp
Normal file
27
AcWing/867/867.cpp
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
#include <bits/stdc++.h>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
int n, a;
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
cin >> n;
|
||||||
|
while (n--) {
|
||||||
|
cin >> a;
|
||||||
|
for (int i = 2; i * i <= a; i++) {
|
||||||
|
if (a % i == 0) {
|
||||||
|
int s = 0;
|
||||||
|
while (a % i == 0) {
|
||||||
|
a /= i;
|
||||||
|
s++;
|
||||||
|
}
|
||||||
|
cout << i << ' ' << s << endl;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (a > 1) {
|
||||||
|
cout << a << ' ' << 1 << endl;
|
||||||
|
}
|
||||||
|
cout << endl;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user