forked from daiwb/Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path94.cpp
More file actions
56 lines (48 loc) · 1.04 KB
/
94.cpp
File metadata and controls
56 lines (48 loc) · 1.04 KB
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 <iostream>
#include <sstream>
#include <algorithm>
#include <iterator>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <cmath>
using namespace std;
#define REP(i,n) for(int i=0;i<(n);++i)
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i)
typedef long long LL;
#define BILLION 1000000000
void run() {
LL res = 0;
LL a = 3, len = 10;
for (LL i = 2; ; ++i) {
if (i % 100000000 == 0) cout << "*** " << i << " ***" << endl;
LL len = (a + i) << 1;
LL h2 = a * a - i * i;
LL h = (LL) sqrt(h2 + 0.0);
if (h * h == h2) {
res += len;
cout << i << " " << a << " " << len << endl;
}
len += 4;
if (len > BILLION) break;
a += 2;
len = (a + i) << 1;
h2 = a * a - i * i;
h = (LL) sqrt(h2 + 0.0);
if (h * h == h2) {
res += len;
cout << i << " " << a << " " << len << endl;
}
len += 2;
if (len > BILLION) {
break;
}
}
cout << res << endl;
}
int main () {
run();
return 0;
}