#include <stdio.h> #include <string.h> #define MAX 20000001 #define TIMAX 200000000 #define WANTED 10001 long long a[MAX]; // A357378 bool seen[TIMAX]; long long b[WANTED]; // inverse of A357378 int w = 1; int main() { memset(seen, 0, sizeof(seen)); memset(b, -1, sizeof(b)); for (int n=0; n<MAX; n++) { for (a[n]=1;; a[n]++) { long long t = a[n/2]*a[n]; if (t>=TIMAX) { goto end; } else if (!seen[t]) { seen[t] = true; if (t<WANTED) { b[t] = n; while (b[w]>=0) { printf("%d %lld\n", w, b[w]); fflush(stdout); w++; if (w==WANTED) { goto end; } } } break; } } } end: return 0; }