2 solutions
-
0
#include<bits/stdc++.h> using namespace std; typedef long long LL; int main() { LL n; cin>>n; map<LL,LL> h; for(LL i=2;i<=n/i;i++) //分解质因数 { while(n%i==0) { h[i]++; n/=i; } } if(n>1) h[n]++; //剩余的最后一个数是质数 bool st=true; for(auto t:h) { if(st) { cout<<t.first; if(t.second>1) { cout<<"^"<<t.second; } st=false; } else { cout<<" * "<<t.first; if(t.second>1) { cout<<"^"<<t.second; } } } return 0; }
- 1
Information
- ID
- 2526
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 5
- Tags
- (None)
- # Submissions
- 9
- Accepted
- 4
- Uploaded By