diff --git a/projecteuler/062/main.cpp b/projecteuler/062/main.cpp new file mode 100644 index 0000000..b59bb2d --- /dev/null +++ b/projecteuler/062/main.cpp @@ -0,0 +1,48 @@ +/* +Cubic Permutations + +The cube, 41063625 (3453), can be permuted to produce two other cubes: 56623104 (3843) and 66430125 (4053). In fact, 41063625 is the smallest cube which has exactly three permutations of its digits which are also cube. + +Find the smallest cube for which exactly five permutations of its digits are cube. +*/ + +#include + +using namespace std; + +typedef long long ll; + +int main(){ + + cout << "Hello this is Patrick" << endl; + auto start = chrono::high_resolution_clock::now(); + + map occs; + map> cubes; + + int n = 1; + ll cube, result; + string s; + + while(true){ + cube = pow(n, 3); + + s = to_string(cube); + sort(s.begin(), s.end()); + + occs[s]++; + cubes[s].push_back(cube); + + if(occs[s] == 5){ + result = cubes[s].front(); + break; + } + n++; + } + + cout << result << endl; + + auto duration = chrono::duration_cast(chrono::high_resolution_clock::now() - start); + cout << (float)duration.count()/1000 << endl; + return 0; +}