Submission details
Task:Distances
Sender:frederikvase
Submission time:2026-04-21 13:04:36 +0300
Language:C++ (C++20)
Status:COMPILE ERROR

Compiler report

input/code.cpp: In function 'int main()':
input/code.cpp:69:29: error: 'mx' was not declared in this scope; did you mean 'mxn'?
   69 |         for (int i = 0; i < mx - 1; i++) {
      |                             ^~
      |                             mxn
input/code.cpp:73:14: error: 'mx' was not declared in this scope; did you mean 'mxn'?
   73 |         k -= mx * (mx - 1) / 2;
      |              ^~
      |              mxn

Code

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

#define sz(x) int(x.size())
#define all(x) begin(x), end(x)

const int mxn = 1e6;
int sieve[mxn];
void make_sieve() {
	for (int i = 2; i < mxn; i++) {
		if (sieve[i]) continue;
		for (int j = i; j < mxn; j += i) {
			sieve[j] = i;
		}
	}
}

vector<int> divisors(int x) {
	vector<int> div = { 1 };
	while (x > 1) {
		int p = sieve[x];
		vector<int> mul = { p };
		for (x /= p; sieve[x] == p; x /= p) {
			mul.push_back(mul.back() * p);
		}
		for (int i = sz(div) - 1; i >= 0; i--) {
			for (int m : mul) div.push_back(div[i] * m);
		}
	}
	return div;
}

bool is_square(ll x) {
	ll xx = sqrt(x) + 0.5;
	return xx * xx == x;
}

signed main() {
	cin.tie(0)->sync_with_stdio(0);

	make_sieve();

	auto divs = divisors(1LL*2*2*2*2*3*3*3*5*7);

	ll n, k;
	cin >> n >> k;

	vector<pair<ll, ll>> a;
	ll l = 1;
	for (ll h : divs) {
		for (ll w = h; w <= 1e4; w++) {
			if (gcd(h, w) == 1 && is_square(h * h + w * w)) {
				l = lcm(l, h);
				a.emplace_back(h, w);
			}
		}
	}

	for (auto &[h, w] : a) {
		w = w * (l / h);
		h = l;
	}

	sort(all(a));

	vector<pair<ll, ll>> res;
	res.emplace_back(1, 0);
	for (int i = 0; i < mx - 1; i++) {
		res.emplace_back(a[i].second + 1, 0);
	}

	k -= mx * (mx - 1) / 2;
	for (int i = 0; i < k; i++) {
		res[i].first--;
	}

	for (int i = 0; sz(res) < n; i++) {
		res.emplace_back(-i - (i == 0 ? 0 : ll(7e8)), a[0].first + i + (i == 0 ? 0 : ll(6.5e8)));
	}

	for (auto [x, y] : res) {
		cout << x << " " << y << "\n";
	}

	return 0;
}