本地测试没问题 ta说Wrong Answer.wrong answer Too short on line 1.
#include<bits/stdc++.h>
using namespace std;
int n;
const int N=1e8+20;
int a[N],tot;
bool b[N];
int main()
{
a[0]=a[1]=1;
cin>>n;
int w=1e7;
for(int i=2;i<=w;i++)
{
if(b[i]==0)
{
a[++tot]=i;
}
for(int j=1;j<=tot&&i*a[j]<=w;j++)
{
b[i*a[j]]=1;
if(i%a[j]==0) break;
}
}
for(int i=1;i<=tot;i++)
{
int w=0;
bool pd=0;
while(n%a[i]==0)
{
n/=a[i];
w++;
pd=1;
}
if(w==1)
{
cout<<a[i]<<' ';
}
if(w>=2)
{
cout<<a[i]<<'^'<<w<<' ';
}
if(n==1)
break;
if(pd)
{
cout<<"* ";
}
}
return 0;
}
悬赏一关