# 喵喵的数学难题

lls笑了笑说：“小老弟你还是太年轻~”

``5``

``````2 3
3 1
5 1``````

``````#include<stdio.h>
#include<stdlib.h>
int n=1e5+5;
int main()
{
int a[n];
memset(a,0,sizeof(a));
int N,x;
scanf("%d",&N);
for(int i = 2;i<=N;i++){
x=i;
for(int j = 2;j*j<=i;j++)
while(x%j==0){
a[j]++;
x/=j;
}
if(x>1)
a[x]++;
}
for(int i = 2;i<=N;i++)
if(a[i])
printf("%d %d\n",i,a[i]);
}
``````

``````#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <bitset>
#include <set>
#include <utility>
using namespace std;
typedef long long ll;
#define inf 0x3f3f3f3
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define lep(i,l,r) for(int i=l;i>=r;i--)
#define ms(arr) memset(arr,0,sizeof(arr))
//priority_queue<int,vector<int> ,greater<int> >q;
const int maxn = (int)1e5 + 5;
const ll mod = 1e9+7;
int n,a[maxn];
void ans(int x)
{
for(int i=2;i*i<=x;i++)
{
while(x%i==0)
{
a[i]++;
x/=i;
}
}
if(x>1) a[x]++;
}
int main()
{
//freopen("in.txt", "r", stdin);
//freopen("out.txt", "w", stdout);
ios::sync_with_stdio(0),cin.tie(0);
scanf("%d",&n);
rep(i,2,n) ans(i);
rep(i,2,n) {
if(a[i])
printf("%d %d\n",i,a[i]);
}
return 0;
}``````