1 solutions
-
0
C++ :
#include<bits/stdc++.h> #define int long long #define D(x) std::cerr<<#x<<'='<<x; int n,pd; void solve(int x){ for(int i=2;x>1&&i<=x;i++){ if(x%i==0){ int cnt=0; while(x%i==0)x/=i,cnt++; if(pd){ printf("* "); } else pd=1; if(cnt>1)printf("%lld^%lld ",i,cnt); else printf("%lld ",i); } } } bool q(int x){ if(x==1)return 0; for(int i=2;i*i<=x;i++)if(x%i==0)return 0; return 1; } signed main(){ scanf("%lld",&n); if(q(n))printf("%lld",n); else solve(n); return 0; }
- 1
Information
- ID
- 9166
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By