Rebased projecteuler folder, now includes all contest programming stuff
This commit is contained in:
33
projecteuler/063/main.cpp
Normal file
33
projecteuler/063/main.cpp
Normal file
@@ -0,0 +1,33 @@
|
||||
#include <iostream>
|
||||
#include <chrono>
|
||||
#include <cmath>
|
||||
|
||||
using namespace std;
|
||||
|
||||
uint intlength(long double i){
|
||||
return floor(log10(i)) + 1;
|
||||
}
|
||||
|
||||
int main(){
|
||||
|
||||
cout << "Hello this is Patrick" << endl;
|
||||
auto start = chrono::high_resolution_clock::now();
|
||||
|
||||
int result = 0;
|
||||
|
||||
for(uint i = 1; i < 10; ++i){
|
||||
for(uint j = 1; j <= 10000; ++j){
|
||||
long double exp = pow(i, j);
|
||||
if(intlength(exp) == j){
|
||||
result++;
|
||||
cout << i << " " << j << " " << exp << endl;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cout << result << endl;
|
||||
|
||||
auto duration = chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start);
|
||||
cout << (float)duration.count()/1000 << endl;
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user