Hello,
I am new to codechef and am practicing questions. I am struck at one ques (code is written in java)
Question
My Attempt
My logic is:
first I found sum of two nos .
now I fetched last digit of the sum . now i eliminated that last digit I fetched by dividing it by 10. and it continues till each digit of sum gets analyzed. whenever each digit is fetched matches required to form it are also stored.
The program executes successfully and it produces the desired results but I don’t know why it still says wrong solution.
Edit: I am so sorry for wrong link. I have updated it
It is correct and accepted solution. Where are you seeing WA ?
It still says wrong answer. I am not allowed to share a screenshot since I am a new user.
You can share anything of a problem if it is not from an ongoing contest
Now I noticed that is not your code. Share your code correctly.
For “0” you need 6 matches
The submission link is of a submission you have mentioned is by some other user, Please check the link once again.
Why is the submission of another user linked under “My attempt” ?
Correct Link of your recent submission.
int dm[]={4,2,5,5,4,5,6,3,7,6};
To make zero we need 6 sticks, you are using 4.
#include<bits/stdc++.h>
using namespace std;
int main()
{
int t;
cin>>t;
while(t–)
{
int s[10]={6,2,5,5,4,5,6,3,7,6};
long long int a,b,r,count=0,sum;
cin>>a>>b;
sum=a+b;
while(sum>0)
{
r=sum%10;
sum=sum/10;
count=count+s[r];
}
cout<<count<<endl;
}
return 0;
} hope u find the result
oh yes. thanks
Thank you so much guys . It was a very silly mistake from my side .You all were so ready to help Thank you. Also I am very sorry for wrong link . I am newbie in programming and to this site and will try to avoid such blunders.