-
Notifications
You must be signed in to change notification settings - Fork 4
/
patrat.cpp
39 lines (36 loc) · 928 Bytes
/
patrat.cpp
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
#include <fstream>
#include <list>
#include <vector>
#include <iostream>
using namespace std;
ifstream in ("patrat.in");
ofstream out ("patrat.out");
unsigned short numSqSum[20001];
const int sq20k = 1000;
//vector<list<pair<int,int> > > sqSums;
int main()
{
//sqSums.resize(20001);
for(int i = 1; i <= sq20k; ++i) {
for(int j = i+1; j <= sq20k; ++j) {
if(i*i+j*j<=20000){
numSqSum[i*i+j*j]++;
//sqSums[i*i+j*j].push_back(make_pair(i,j));
}
}
}
int a,b;
in >> a >> b;
int cnt = 0;
for(int i = a; i <= b; ++i) {
if(numSqSum[i]>=2) {
out << i << '\n';
// for(auto i2 = sqSums[i].begin(); i2 != sqSums[i].end();++i2) {
// cout << i << ' ' << i2->first << ' ' <<i2->second << '\n';
// }
cnt++;
}
}
if(cnt==0)out << cnt << '\n';
return 0;
}