#include <stdio.h> #include <string.h> #include <stdlib.h> long long gcd(long long a, long long b) { while (a != 0) { long long c = a; a = b%a; b = c; } return (b<0) ? -b : +b; } #define RING (1LL<<(sizeof(unsigned short)*8)) bool seen[RING]; unsigned short slow = 0; long long low = 0; long long high = RING; long long other(long long p) { while (seen[slow]) { seen[slow] = false; slow++; low++; high++; } long long v=low; unsigned short sv=slow; while (v<high) { if (!seen[sv] && gcd(p,v)==1) { seen[sv] = true; return v; } sv++; v++; } exit(1); } int main() { memset(seen, 0, sizeof(seen)); seen[0] = true; seen[1] = true; seen[2] = true; long long r=0; long long mx=0; long long pp, p, v; for (long long n=1; r<10000; n++) { if (n==1) { v=1; } else if (n==2) { v=2; } else { v=other(pp); } if (mx<v) { mx=v; printf("%lld %lld\n", ++r, n); fflush(stdout); } pp=p; p=v; } return 0; }