1 solutions
-
0
C++ :
#include <bits/stdc++.h> using namespace std; void f(int x) { bool flag = true; for (int i = 2; i <= x / i; i ++) { if (x % i != 0) continue; int cnt = 0; while (x % i == 0) { cnt ++; x /= i; } if (!flag) cout << '*'; flag = false; if (cnt > 1) printf("%d^%d", i, cnt); else if (cnt == 1) printf("%d", i); } if (x != 1) { if (flag) printf("%d", x); else printf("*%d", x); } } int main() { int n; cin >> n; f(n); return 0; }
- 1
Information
- ID
- 17295
- Time
- 1000ms
- Memory
- 128MiB
- Difficulty
- (None)
- Tags
- # Submissions
- 0
- Accepted
- 0
- Uploaded By