大师 • 15天前
using namespace std; bool sushu(int num);
int main() {
int a, b, d, sum = 0;
cin >> a >> b >> d;
string s = " ";
for (int i = a; i <= b; i++) {
if (sushu(i)) {
s = to_string(i);
}
for (int j = 0; j < s.length(); j++) {
if (s[j] - 48 == d) {
sum++;
break;
}
}
s = " ";
}
cout << sum;
return 0;
}
bool sushu(int num) {
if (num <= 1)
return false;
for (int i = 2; i * i <= num; i++) {
if (num % i == 0)
return false;
}
return true;
}
评论:
请先登录,才能进行评论