intmain(){ ifstream fin("ariprog.in"); ofstream fout("ariprog.out"); intconst SIZE = 250; int N, M; fin >> N >> M;
vector<bool> set(SIZE * SIZE * 2 + 1, false); for (int i = 0; i <= M; ++i) { for (int j = 0; j <= M; ++j) { set[i * i + j * j] = true; } }
vector<pair<int, int>> result; auto limit = M * M * 2; for (int i = 0; i < limit; ++i) { bool found = true; for (int j = 1; j < limit - i; ++j) { if (j * (N - 1) + i > limit) { found = false; break; }
for (int k = N - 1; k >= 0; --k) { auto val = i + k * j;
if (val > limit) { found = false; break; }
if (!set[val]) { found = false; break; } else { found = true; } } if (found) { result.emplace_back(std::make_pair(i, j)); } } }