This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.
#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;