int main(){ int m, n, x = 1; int count = 0, realCount = 0; //freopen("a.in","r",stdin); scanf("%d %d", &m, &n); while(x++){ if (!isPrimer(x)){ continue; } count++; if (count>=m && count<=n){ if (realCount % 10 != 0){ printf(" "); } printf("%d", x); if (realCount % 10 == 9){ printf("\n"); } realCount++; } if (count > n){ break; } } return 0; }
int nextPrimer(int tableSize) { while(!isPrimer(tableSize)) { tableSize++; } return tableSize; }
int countPrimes(int n) { vector<bool> isPrimer(n, true); for(int i=2; i*i<n; i++){ if (isPrimer[i]){ for(int j=i*i; j<n; j+=i){ isPrimer[j] = false; } } } int cnt = 0; for(int i=2; i<n; i++){ if (isPrimer[i]) { //cout << i << ", "; cnt++; } } return cnt; }