全是RE
查看原帖
全是RE
856014
王仁之2013楼主2024/8/15 09:45
#include <iostream>
#include <cstdio>
#include <cmath> 
using namespace std;
bool isPrime(int n) {
    if (n <= 1) return false;
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0) return false;
    }
    return true;
}
int main() {
    int k,d;
    scanf("%d %d",&k,&d);
    int a[100000] = {0}; 
    int count = 0; 
    for (int i = 2; i <= k; i++) {
        if (isPrime(i)) {
            a[count++] = i; 
        }
    }
    for (int i = 0; i < d; i++) {
        int x;
        scanf("%d",&x);
        printf("%d\n",a[x-1]);
    }
    
    return 0;
}
2024/8/15 09:45
加载中...