-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathariprog.cpp
More file actions
61 lines (50 loc) · 1012 Bytes
/
ariprog.cpp
File metadata and controls
61 lines (50 loc) · 1012 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
/*
ID: dswei191
LANG: C++
TASK: ariprog
*/
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
using namespace std;
ofstream fout("ariprog.out");
ifstream fin("ariprog.in");
int N, M;
int h[125001];
vector<pair<int,int > > vec;
bool valid(int a, int b){
for(int n = 0; n < N; n++){
if(h[a + n * b] != 1){
return false;
}
}
return true;
}
int main(){
fin >> N >> M;
for(int i = 0; i <= M; i++){
for(int j = 0; j <=M; j++){
int t = i * i + j * j;
h[t] = 1;
}
}
int M2 = M*M*2;
int maxB = M2 / (N-1);
bool flag = false;
for (int b = 1; b <= maxB; b++){
for(int a = 0; a <= M2; a++){
if(a + b * (N-1) > M2){
break;
}
if(valid(a, b)){
flag = true;
fout<< a << " "<<b <<endl;
}
}
}
if(flag == false){
fout << "NONE"<<endl;
}
return 0;
}