#include #include constexpr long long mx = 10'001; std::vector a(mx); bool aligned(long long i, long long j, long long k) { return (i-j) * (a[j]-a[k]) == (j-k) * (a[i]-a[j]); } int main() { for (int n = 1; n < mx; n++) { if (n==1) { a[n] = 1; // by definition } else if (n==2) { a[n] = 1; // only one point so far } else { a[n] = 2; // two points are always aligned for (int k = 1; k < n-1; k++) { long long v = 2; for (int i = 1; i < k; i++) { if (aligned(i, k, n-1)) { v++; } } if (a[n] < v) { a[n] = v; } } } std::cout << n << ' ' << a[n] << std::endl; } return 0; }