Files
python/LuoGu/RuMen/P2043.cpp
HuangHai 1f397eca87 'commit'
2025-08-30 18:35:01 +08:00

23 lines
689 B
C++
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#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;
}
}