Files
python/LuoGu/RuMen/P2043.cpp

23 lines
689 B
C++
Raw Normal View History

2025-08-30 18:35:01 +08:00
#include <bits/stdc++.h>
using namespace std;
int a[10001] = {0}, n; //数组很大,记得开在外面哦
int main() {
ios::sync_with_stdio(false); //读入输出优化的强迫症
cin >> n;
//1就不用了,从2到n一个一个来
for (int i = 2; i <= n; i++) {
//备份一下,不然等会被除掉了
int i2 = i;
//从2开始判断是否可以整除
for (int j = 2; j <= i; j++)
while (i2 % j == 0) {
a[j]++;
i2 /= j;
}
}
for (int i = 1; i <= 10000; i++) //输出
if (a[i] != 0) {
cout << i << " " << a[i] << endl;
}
}