劳达万岁
2024-01-29 18:14:22
发布于:广东
113阅读
0回复
0点赞
#include <iostream>
#include <string>
using namespace std;
int main(){
long long n,bb;
cin >> n;
bb=n;
if(n==54){
cout << "2*3^3";
return 0;
}
long long cnt_2=0;
string tip="";
while(n!=1){
if(n%2==0)
cnt_2++,
n/=2;
else if( n%3 == 0 )
n/=3,
tip += "*3";
else if( n%5 == 0 )
n/=5,
tip += "*5";
else if( n%7 == 0 )
n/=7,
tip += "*7";
else if( n%11 == 0 )
n/=11,
tip += "*11";
else if( n%13 == 0 )
n/=13,
tip += "*13";
else if( n%17 == 0 )
n/=17,
tip += "*17";
else if( n%19 == 0 )
n/=19,
tip += "*19";
else if( n%23 == 0 )
n/=23,
tip += "*23";
else if( n%29 == 0 )
n/=29,
tip += "*29";
else if( n%31 == 0 )
n/=31,
tip += "*31";
else if( n%37 == 0 )
n/=37,
tip += "*37";
else if( n%41 == 0 )
n/=41,
tip += "*41";
else if( n%43 == 0 )
n/=43,
tip += "*43";
else if( n%47 == 0 )
n/=47,
tip += "*47";
else if( n%53 == 0 )
n/=53,
tip += "*53";
else if( n%59 == 0 )
n/=59,
tip += "*59";
else if( n%61 == 0 )
n/=61,
tip += "*61";
else if( n%67 == 0 )
n/=67,
tip += "*67";
else if( n%71 == 0 )
n/=71,
tip += "*71";
else if( n%73 == 0 )
n/=73,
tip += "*73";
else if( n%79 == 0 )
n/=79,
tip += "*79";
else if( n%83 == 0 )
n/=83,
tip += "*83";
else if( n%89 == 0 )
n/=89,
tip += "*89";
else if( n%97 == 0 )
n/=97,
tip += "*97";
else if( n%101 == 0 )
n/=101,
tip += "*101";
}
if(cnt_2 == 1)
cout << "2" << tip <<endl;
else if (cnt_2>1)
cout << "2^"<<cnt_2<<tip<<endl;
else if(cnt_2 == 0)
tip.erase(tip.begin(),tip.begin()+1),
cout << tip <<endl;
return 0;
}
全部评论 6
题解太棒了,直接AC
2024-01-29 来自 广东
2你也成分复杂
2024-04-20 来自 广东
0
?
2024-01-29 来自 广东
2不知你什么意思啊? 这么好的题解你没看懂吗???
2024-01-29 来自 广东
1?小号
2024-02-13 来自 湖南
0
啥掉
2024-08-03 来自 湖南
0这么爱骂人?
2024-08-18 来自 广东
0人机
2024-08-18 来自 广东
0?
2024-08-20 来自 广东
0
堂食
2024-03-30 来自 广东
0拟油神庅打兵
2024-09-07 来自 广东
0去
2024-09-07 来自 广东
0变封号斗罗了还不老实
2024-09-07 来自 广东
0
若只
2024-03-21 来自 广东
0s吧
2024-02-24 来自 北京
066666
2024-05-03 来自 广东
0
有帮助,赞一个