提交时间:2023-08-22 09:38:52
运行 ID: 99136
#include<bits/stdc++.h> //#define int long long using namespace std; namespace Fast{ inline int fr(){ register int x = 0,f = 1; static char c = getchar(); while (c < '0' || c > '9'){ if (c == '-'){ f = -1; } c = getchar(); } while (c >= '0' && c <= '9'){ x = (x << 1) + (x << 3) + (c ^ 48); c = getchar(); } return x * f; } inline void fw(int x){ if (x < 0){ x = -x; putchar('-'); } if (x > 9){ fw(x / 10); } putchar(x % 10 + 48); } } using namespace Fast; const int maxn = 1e7; bool f[maxn + 5]; vector <int> prime; void sushu(){ f[1] = true; for (int i = 2;i <= maxn;i++){ if (!f[i]){ prime.push_back(i); } for (int j = 0;j < prime.size();j++){ int k = prime[j]; if (i * k > maxn){ break; } f[i * k] = true; if (i % k == 0){ break; } } } } void slove(int x){ if (x <= maxn && !f[x]){ fw(x); return ; } bool fl = true; for (int i = 0;i < prime.size();i++){ int j = prime[i]; if (x % j == 0){ while (x % j == 0){ x /= j; if (fl){ fw(j); fl = false; } else{ putchar('*'); fw(j); } } } } } signed main(){ int n = fr(); sushu(); cout<<n<<'='; slove(n); return 0; }