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 48 49 50 51 52 53 54 55 56
|
#include <cstdio> #include <cstring> #include <algorithm> #include <cstdlib> #include <string> #include <set> using namespace std;
typedef long long LL; const int inf = 0x3f3f3f3f; const int maxn = 126010; bool vis[maxn];
int main() { freopen("ariprog.in", "r", stdin); freopen("ariprog.out", "w", stdout); int n, m, num = 0; scanf("%d%d", &n, &m); for (int i = 0; i <= m; ++i) { int k = i * i; for (int j = 0; j <= i; ++j) { vis[k + j * j] = true; } } num = m * m * 2; bool flag = true; for (int i = 1; i <= num; ++i) { for (int j = 0; j <= num; ++j) { if (i * (n - 1) + j > num) { break; } bool ok = true; int st = j, tmp = n; while (tmp--) { if (!vis[st]) { ok = false; break; } st += i; } if (ok) { printf("%d %d\n", j, i); flag = false; } } } if (flag) { puts("NONE"); } return 0; }
|