#include<stdio.h>
#include<cstring>
using namespace std;
const int N=4e7,M=3e7;
int tot,f[M],su[N>>1];
char s[500];
inline void sai(int maxe){
for(int i=2;i<=maxe;++i){
if(!f[i]){
f[i]=i;
su[++tot]=i;
}
for(int j=1;j<=tot;++j){
if(i*su[j]>maxe){
break;
}
f[i*su[j]]=su[j];
if(i%su[j]==0){
break;
}
}
}
}
inline void fen(int x){
int pas=f[x],ji=0;
bool er=0;
while(f[x]){
if(f[x]!=pas){
if(er){
printf("*");
}
er=1;
printf("%d^%d",pas,ji);
pas=f[x];
ji=0;
}
ji++;
x/=f[x];
}
if(er){
printf("*");
}
printf("%d^%d",pas,ji);
}
int main(){
sai(M);
while(true){
printf("Enter the number=\n");
gets(s);
int now=0,len=strlen(s);
bool e=0;
for(int i=0;i<len;++i){
if(s[i]>='0'&&s[i]<='9'){
e=1;
now*=10;
now+=(s[i]-'0');
if(now>N){
break;
}
}
}
if(!e){
break;
}
if(now>N){
printf("Prime? No!\nThe number is too large!\n\n");
continue;
}
printf("Prime? ");
if(f[now]==now){
printf("Yes!\n\n");
continue;
}
printf("No!\n");
if(now==1){
printf("\n");
continue;
}
printf("%d=",now);
fen(now);
printf("\n\n");
}
return 0;
}
/**
* ┏┓ ┏┓+ +
* ┏┛┻━━━┛┻┓ + +
* ┃ ┃
* ┃ ━ ┃ ++ + + +
* ████━████+
* ◥██◤ ◥██◤ +
* ┃ ┻ ┃
* ┃ ┃ + +
* ┗━┓ ┏━┛
* ┃ ┃ + + + +Code is far away from
* ┃ ┃ + bug with the animal protecting
* ┃ ┗━━━┓ 神兽保佑,代码无bug
* ┃ ┣┓
* ┃ ┏┛
* ┗┓┓┏━┳┓┏┛ + + + +
* ┃┫┫ ┃┫┫
* ┗┻┛ ┗┻┛+ + + +
*/
by ThinkofBlank @ 2018-08-09 09:02:16
那证明你的电脑比luogu服务器还好
by localhost @ 2018-09-08 23:47:33