Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- ID: mickyta1
- TASK: ariprog
- LANG: C++
- */
- #include <bits/stdc++.h>
- using namespace std;
- typedef pair<int, int> pii;
- const int N = 125000 + 5;
- vector<pii> ans;
- vector<int> bisq;
- bool isBisq[N];
- bool comp(const pii &lhs, const pii &rhs){
- if(lhs.second != rhs.second){
- return lhs.second < rhs.second;
- }
- return lhs.first < rhs.first;
- }
- int main(){
- freopen("ariprog.in", "r", stdin);
- freopen("ariprog.out", "w", stdout);
- int n, limBisq;
- scanf("%d%d", &n, &limBisq);
- for(int i = 0; i <= limBisq; ++i){
- for(int j = i; j <= limBisq; ++j){
- int x = i * i + j * j;
- bisq.push_back(x);
- isBisq[x] = true;
- }
- }
- sort(bisq.begin(), bisq.end());
- bisq.resize(unique(bisq.begin(), bisq.end()) - bisq.begin());
- for(int i = 0; i < (int)bisq.size() - 1; ++i){
- for(int j = i + 1; j < bisq.size(); ++j){
- int a = bisq[i];
- int d = bisq[j] - bisq[i];
- if(a + (n - 1) * d > bisq.back()){
- break;
- }
- bool ok = true;
- for(int k = 1; k <= n; ++k){
- if(!isBisq[a + (k - 1) * d]){
- ok = false;
- break;
- }
- }
- if(ok){
- ans.emplace_back(a, d);
- }
- }
- }
- sort(ans.begin(), ans.end(), comp);
- if(ans.empty()){
- cout << "NONE\n";
- }
- for(pii p : ans){
- cout << p.first << ' ' << p.second << '\n';
- }
- fclose(stdin);
- fclose(stdout);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement