第36549题 组合题
阅读程序(第一题):统计数位和为素数的素数个数

阅读下面程序,完成后面的判断题和单选题。判断题正确填 A,错误填 B。

#include <cstdio>

int isPrime(int x) {
    if (x < 2) return 0;
    for (int i = 2; i * i <= x; ++i)
        if (x % i == 0) return 0;
    return 1;
}

int main() {
    int n;
    scanf("%d", &n);
    int ans = 0;
    for (int i = 2; i <= n; ++i) {
        if (isPrime(i)) {
            int s = 0, t = i;
            while (t > 0) {
                s += t % 10;
                t /= 10;
            }
            if (isPrime(s)) ++ans;
        }
    }
    printf("%d\n", ans);
    return 0;
}
{{ option.label }}
子题{{ index + 1 }} {{ child.type_label }}
{{ option.label }}
✓ 正确 ◐ 部分正确 ✗ 错误
程序运行统计
暂无判题统计
知识点:
提交{{ questionInfo.stats ? questionInfo.stats.submit_count : 0 }}次 正确率{{ statsAccuracy }}%
答案解析