// AC (8ms, 696KB)
#include
main()
{
int input,a,b,i,n;
n=0;
while (scanf("%d",&input)!=EOF)
{
for (i=2;i<=input;i++)
{
b=0;
while(input%i==0)
{
input/=i;
b+=1;
}
if (b==0) continue;
if(n==0)
{
if (b==1)
{
printf("%d ",i);
}
else
{
printf("%d^%d ",i,b);
}
n=1;
}
else
if (b==1)
{
printf("* %d ",i);
}
else
{
printf("* %d^%d ",i,b);
}
}
n=0;
puts("");
}
}
#include
main()
{
int input,a,b,i,n;
n=0;
while (scanf("%d",&input)!=EOF)
{
for (i=2;i<=input;i++)
{
b=0;
while(input%i==0)
{
input/=i;
b+=1;
}
if (b==0) continue;
if(n==0)
{
if (b==1)
{
printf("%d ",i);
}
else
{
printf("%d^%d ",i,b);
}
n=1;
}
else
if (b==1)
{
printf("* %d ",i);
}
else
{
printf("* %d^%d ",i,b);
}
}
n=0;
puts("");
}
}
沒有留言:
張貼留言