The first two test cases are not being passed by my program. I saw the solution given by sir and I understand that too but I want to know why my program can not pass the test cases .Whatever input I give by myself, I am getting the correct output for that. Please look into my program and help me
#include
using namespace std;
int main() {
unsigned long long int n,num,sum=0;
//unsigned long long A[100000]={0};
cin>>n;
if(n> 100000000000000000)
return 0;
num=n;
int first_variable_check_if_zero=0;
int k=0,p=1,store=0;
while(num>=1)
{
int remainders=num%10;
int quotient=num/10;
int minusNine=9-remainders;
first_variable_check_if_zero=remainders;
if(minusNine<remainders)
{
store=minusNine;
}
else
store=remainders;
if(quotient==0 && store==0)
store=remainders;
sum+=(pstore);
p=10;
k++;
num/=10;
}
cout<<sum;
return 0;
}
Chewbacca and Number first two test cases not passed
Check for the input
9864839
correct output should be
9134139
No, correct output should be 9134130. Wasted alot of time finding where I am wrong.
1 Like