I wrote the following code but it fails test cases 0 and 1. Please explain the mistake in my code.
#include < iostream >
#include < cmath >
using namespace std;
int main()
{
long long int n;
cin>>n;
int num = n;
int ans = 0;
int digit;
while(n>0)
{
digit = n%10;
ans = ans + pow(digit,3);
n = n/10;
}
if(ans==num)
{
cout<<"true";
}
else
{
cout<<"false";
}
return 0;
}