-
Notifications
You must be signed in to change notification settings - Fork 0
/
00386.cpp
43 lines (36 loc) · 1.08 KB
/
00386.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
40
41
42
43
#include <bits/stdc++.h>
using namespace std;
#define ll long long
bool comp(vector<ll> a, vector<ll> b){
if(a[1] != b[1]) return a[1] < b[1];
else if(a[0] != b[0]) return a[0] < b[0];
else return a[2] < b[2];
}
int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
vector<vector<vector<ll>>> hi(500, vector<vector<ll>>());
for(ll i = 2; i <= 200; i++){
for(ll j = i; j <= 200; j++){
for(ll k = j; k <= 200; k++){
ll ik = i*i*i;
ll jk = j*j*j;
ll kk = k*k*k;
ll cb = cbrt(ik+jk+kk);
ll cbk = cb*cb*cb;
if(ik+jk+kk == cbk){
hi[cb].push_back({i, j, k});
}
}
}
}
for(ll i = 2; i <= 200; i++){
// sort(hi[i].begin(), hi[i].end(), comp);
for(auto x: hi[i]){
cout << "Cube = " << i << ", Triple = (" << x[0] << "," << x[1] << "," << x[2] << ")\n";
}
}
return 0;
}