文章
68
粉丝
691
获赞
26
访问
582.3k
题意还算清晰,照着来即可,但是会爆int,int只得了66分
int main() {
int n;
while (cin >> n) {
vec v;
for (int i = 2; i <= sqrt(n) && n > 1; i++) {
while (n%i == 0) {
v.push_back(i); n /= i;
}
}
if (n != 1)v.push_back(n);
ll sign = 1, t = 0, i = 0, j = 0; string s;
for (i; i < v.size(); i = j) {
int cnt = 1;
for (j = i + 1; j < v.size() && v[j] == v[i]; j++) {
cnt++;
}
if (cnt > 1)s += to_string(v[i]) + to_string(cnt);
else s += to_string(v[i]);
}
if (s.size() > 0)t = stoll(s);
for (int i = 2; i <= sqrt(t) && sign; i++) {
if (t%i == 0)sign = 0;
}
cout << t << endl;
if (sign&&t > 1)cout << "Yes" << endl;
else cout << "No" << endl;
}
}
登录后发布评论
暂无评论,来抢沙发