forked from srikanthmalipatel/Spoj-Problems
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCUBES-7061600-src.cpp
More file actions
48 lines (46 loc) · 1.13 KB
/
CUBES-7061600-src.cpp
File metadata and controls
48 lines (46 loc) · 1.13 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
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<cctype>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<bitset>
using namespace std;
#define pb push_back
#define pi 3.141592653589793238462643383
int main()
{
int i,j;
int a,b,c,d,sum;
vector<int> v(101);
vector<int>::iterator it;
for(i=1;i<=100;i++)
v[i] = i*i*i;
for(a=2;a<=100;a++){
for(b=2;b<=a-1;b++){
for(c=b+1;c<=a-1;c++){
sum = v[b]+v[c];
sum = v[a]-sum;
if(binary_search(v.begin()+1,v.end(),sum)){
it = lower_bound(v.begin()+1,v.end(),sum);
d = (int)(it - v.begin());
if(d<c)
continue;
vector<int> ans;
ans.pb(b);
ans.pb(c);
ans.pb(d);
sort(ans.begin(),ans.end());
printf("Cube = %d, Triple = (%d,%d,%d)\n",a,ans[0],ans[1],ans[2]);
}
}
}
}
}