Submission #6434609


Source Code Expand

#include <bits/stdc++.h>
using namespace std;

const int N = (int) 1e5 + 5;

int n;
int nprime;
int p[N], f[N];

void sieve() {
	int LIM = 55555;
	for  (int i = 2; i <= LIM; i++) {
		if (f[i] == 0) f[i] = p[++nprime] = i;
		int j = 0;
		while (j < nprime && p[j] < f[i] && p[j + 1] * i <= LIM) {
			f[p[j + 1] * i] = p[j + 1];
			j++;
		}
	}
}

int main() {
	//freopen(".inp", "r", stdin); freopen(".out", "w", stdout);
	sieve();
	cin >> n;
	for (int i = 1; i <= nprime; i++)
		if (p[i] % 5 == 1) {
			cout << p[i] << " ";
			n--;
			if (n == 0) break;
		}
	return 0;
}

Submission Info

Submission Time
Task D - Five, Five Everywhere
User sesshomalong
Language C++14 (GCC 5.4.1)
Score 400
Code Size 601 Byte
Status AC
Exec Time 2 ms
Memory 512 KB

Judge Result

Set Name Sample All
Score / Max Score 0 / 0 400 / 400
Status
AC × 3
AC × 5
Set Name Test Cases
Sample sample_01.txt, sample_02.txt, sample_03.txt
All in01.txt, in02.txt, sample_01.txt, sample_02.txt, sample_03.txt
Case Name Status Exec Time Memory
in01.txt AC 2 ms 512 KB
in02.txt AC 2 ms 512 KB
sample_01.txt AC 2 ms 512 KB
sample_02.txt AC 2 ms 512 KB
sample_03.txt AC 2 ms 512 KB