#include #include std::vector primes; bool aligned(long long i, long long j, long long k) { return (i-j) * (primes[j]-primes[k]) == (j-k) * (primes[i]-primes[j]); } int main() { std::vector sieve(104729 + 1); for (long long v = 2; v < sieve.size(); v++) { if (!sieve[v]) { primes.push_back(v); for (long long m = v; m < sieve.size(); m+=v) { sieve[m] = true; } } } for (long long n = 0; n < primes.size(); n++) { long long v = 0; if (n==0) { v = 1; // only one point so far } else { v = 2; // two points are always aligned for (long long k = 0; k < n; k++) { long long w = 2; for (long long i = 0; i < k; i++) { if (aligned(i, k, n)) { w++; } } if (v < w) { v = w; } } } std::cout << n+1 << ' ' << v << std::endl; } return 0; }