_B4U_ wrote:
Darnit, I didn't even get the pinata... guess this one was easier than I thought.
Anyways, for any who might find it interesting, this was what I did:
#include <iostream.h>
#include <math.h>
int sumNums(int i);
void main(void)
{
for(int i=100000; i<=999999; i++)
{
if((pow(i , 1.0/2.0)) - int(pow(i , 1.0/2.0)) == 0 && (pow(i , 1.0/3.0) - int(pow(i , 1.0/3.0)) == 0) && sumNums(i) == 43)
{
cout << i << endl;
}
else if((pow(i , 1.0/2.0) - int(pow(i , 1.0/2.0)) == 0) && (i < 500000) && sumNums(i) == 43)
{
cout << i << endl;
}
else if((pow(i , 1.0/3.0) - int(pow(i , 1.0/3.0)) == 0) && (i < 500000) && sumNums(i) == 43)
{
cout << i << endl;
}
}
//int i = 234578;
//cout << i % 10 << "\t" << ((i % 100) - (i % 10)) / 10 << "\t" << ((i % 1000) - (i % 100)) / 100 << "\t";
//cout << ((i % 10000) - (i % 1000)) / 1000 << "\t" << ((i % 100000) - (i % 10000)) / 10000 << "\t" << ((i % 1000000) - (i % 100000)) / 100000 << endl;
//cout << (i % 10) + (((i % 100) - (i % 10)) / 10) + (((i % 1000) - (i % 100)) / 100) + (((i % 10000) - (i % 1000)) / 1000) + (((i % 100000) - (i % 10000)) / 10000) + (((i % 1000000) - (i % 100000)) / 100000) << endl;
//cout << sumNums(i) << endl;
//if((i % 10) + (((i % 100) - (i % 10)) / 10) + (((i % 1000) - (i % 100)) / 100) + (((i % 10000) - (i % 1000)) / 1000) + (((i % 100000) - (i % 10000)) / 10000) + (((i % 1000000) - (i % 100000)) / 100000) == 43)
}
int sumNums(int i)
{
return ((i % 10) + (((i % 100) - (i % 10)) / 10) + (((i % 1000) - (i % 100)) / 100) + (((i % 10000) - (i % 1000)) / 1000) + (((i % 100000) - (i % 10000)) / 10000) + (((i % 1000000) - (i % 100000)) / 100000));
}(Shrunk to reduce size)
It looks sloppy, but it works fine and dandy.

Your add up the digits looks about as ugly as my add up the digits formula I used in EXCEL.
But again, we weren't being graded on the way we got the answer ... just the answer.
It's too bad people spilled the beans on the boards on this one. The payout could have been much better. No item prize for me, either. I need to figure out a way to be notified when the new LC or MP is up.
