forked from daiwb/Algorithm
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path45.cpp
More file actions
73 lines (63 loc) · 1.21 KB
/
45.cpp
File metadata and controls
73 lines (63 loc) · 1.21 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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#include <iostream>
#include <sstream>
#include <algorithm>
#include <iterator>
#include <vector>
#include <set>
#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)
typedef long long LL;
vector<string> split( const string& s, const string& delim =" " ) {
vector<string> res;
string t;
for ( int i = 0 ; i != s.size() ; i++ ) {
if ( delim.find( s[i] ) != string::npos ) {
if ( !t.empty() ) {
res.push_back( t );
t = "";
}
} else {
t += s[i];
}
}
if ( !t.empty() ) {
res.push_back(t);
}
return res;
}
int s2i(string s) {
stringstream ss;
ss << s;
int res;
ss >> res;
return res;
}
string i2s(int n) {
stringstream ss;
ss << n;
string res;
ss >> res;
return res;
}
void run() {
for (LL i = 286; ; ++i) {
LL t = i * (i + 1) / 2;
//cout << t << endl;
LL a = t * 24 + 1;
LL b = (LL) sqrt(a + 0.5);
//cout << a << " " << b << endl;
if (b * b != a) continue;
if ((b + 1) % 6 != 0) continue;
a = t * 8 + 1;
b = (LL) sqrt(a + 0.5);
if (b * b != a) continue;
if ((b + 1) % 4 != 0) continue;
cout << t << endl;
return;
}
}
int main() {
run();
}