#include <stdio.h> #include <string.h> #define MAX (1LL<<30) bool *notsf = 0; int main() { notsf = new bool[MAX]; memset(notsf, 0, MAX * sizeof(*notsf)); for (long long n=2, n2=n*n; n2<MAX; n++, n2=n*n) { for (long long m=n2; m<MAX; m+=n2) { notsf[m] = true; } } long long n = 0; long long v = 4; long long nb = 0; printf("%lld %lld\n", ++n, v); fflush(stdout); for (long long k=1; k<MAX; k++) { if (notsf[k]) { // not squarefree, ignore it } else { nb++; if (v==nb) { v=k; printf("%lld %lld\n", ++n, v); fflush(stdout); } } } delete[] notsf; return 0; }