-
Notifications
You must be signed in to change notification settings - Fork 0
/
problem62_2.C
70 lines (50 loc) · 1.28 KB
/
problem62_2.C
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
//===========================================
// problem62_2.C
//
// written by lina <lina.oahz@gmail.com>
// start: Sat Mar 2 12:59:49 SGT 2013
// end: Sat Mar 2 14:14:12 SGT 2013
//
//============================================
//============================================
// Inculde
//============================================
#include <iostream>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <sstream>
#include <string>
using namespace std;
//============================================
// main code area
//============================================
bool is_cube(long n){
int cuber = cbrtl(n);
if( (long) cuber*cuber*cuber == n)
return true;
return false;
}
#define N 10000
int main(){
int i;
for(i=345; i< N; i++){
long a = pow(i,3);
stringstream ss1;
ss1 << a;
string s = ss1.str();
int count = 0;
do{
long temp = 0;
istringstream buffer(s);
buffer >> temp;
if( is_cube (temp) )
count++;
}while(next_permutation(s.begin(), s.end()));
if(count == 5){
cout << a << endl;
break;
}
}
return 0;
}