有大佬帮一下吗?
原题链接:114490.【入门】JHN数2026-05-03 21:20:02
发布于:广东
请教各位大佬,本人已尝试多种算法还是无法AC,请给指点一下
链接描述
#include <bits/stdc++.h>
using namespace std;
long long st(const string& s) {
long long res = 0;
for (char c : s) {
if (c >= '0' && c <= '9') {
res = res * 10 + (c - '0');
}
}
return res;
}
bool isP(long long x) {
string s = to_string(x);
return s == string(s.rbegin(), s.rend());
}
int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);
string n_str;
cin >> n_str;
long long n = st(n_str);
if (n % 2 == 0) {
cout << "no";
return 0;
}
if (!isP(n)) {
cout << "no";
return 0;
}
set<long long> f;
for (long long i = 1; i * i <= n; i++) {
if (n % i == 0) {
if (i >= 10 && isP(i)) {
f.insert(i);
}
long long other = n / i;
if (other >= 10 && isP(other)) {
f.insert(other);
}
}
}
cout << (f.size() >= 2 ? "yes" : "no");
return 0;
}
全部评论 2
AI 都做不出来说明数据错了
4天前 来自 浙江
0我的评价是:国际信奥赛题(估计之有fl能过)
4天前 来自 浙江
0

















有帮助,赞一个