-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathariprog.cpp
More file actions
47 lines (40 loc) · 742 Bytes
/
Copy pathariprog.cpp
File metadata and controls
47 lines (40 loc) · 742 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
/*
ID: th3c0r11
TASK: ariprog
LANG: C++14
*/
#include <bits/stdc++.h>
using namespace std;
int nMax, m;
std::unordered_set<int> bisquares;
int main()
{
ifstream in{"ariprog.in"};
ofstream out{"ariprog.out"};
in >> nMax >> m;
for (int p = 0; p <= m; ++p) {
for (int q = p; q <= m; ++q) {
bisquares.insert(p*p+q*q);
}
}
int matches = 0;
for (int b = 1; b <= m*m; ++b) {
for (int a = 0; a <= m*m; ++a) {
bool sequenceOK = true;
for (int n = 0, value = a; n < nMax; ++n) {
if (bisquares.find(value) == bisquares.end()) {
sequenceOK = false;
break;
}
value += b;
}
if (sequenceOK) {
++matches;
out << a << ' ' << b << '\n';
}
}
}
if (matches == 0) {
out << "NONE\n";
}
}