#include
#include
using namespace std;
int main() {
string big_number = "7316717...........52963450";
unsigned long long biggest = 0;
unsigned long long test_biggest = 0;
for(int i=0; i
for(int j=0; j<5; j++) {
if(convert_me[j]-'0' == 0)
break;
if(test_biggest == 0) {
test_biggest = convert_me[j]-'0';
continue;
}
test_biggest *= convert_me[j]-'0';
if(j==4)
biggest = ( (test_biggest > biggest) ? test_biggest : biggest);
}
test_biggest = 0;
}
cout << biggest << endl;
return 0;
}
time: 0.002s
Optimizations would be simple but not needed as its such a simple problem. (e.g, increment i by 4 if it finds a zero)
--NotMyFault
libraries are iostream and string
ReplyDeleteWhat you learned until knowing programming so well?
Delete