Display wrong answer even all the test cases are passed.

#include
using namespace std;
int main()
{
long long int t,tot=0,i,n,b,m,k,time;
cin>>t;
for(i=0;i<t;i++)
{
cin>>n>>b>>m;
while(n>0)
{
if(n%2==0)
{
k=n/2;
time=km;
if(n==1)
{
b=0;
}
tot=tot+time+b;
n=n-k;
m=m
2;

            }
            else
            {
                k=(n+1)/2;
                time=k*m;
                if(n==1)
                {
                    b=0;
                }
                tot=tot+time+b;
                n=n-k;
                m=m*2;
            }



        }
        cout<<tot<<endl;


}
return(0);
}

Provide the question link as well so one can figure out the mistake in your solution.
And maybe you passed the Sample test case given in question. The real test cases are much more complex.
Hope I helped :slight_smile:

2 Likes

hey your logic seems correct but only mistake done by you is every time you should initialize tot to 0.please comment if you still have any problem.

1 Like

Guys, please give Q link along with your code. In a website with hundreds of Q, its not at all easy to see which Q you are pointing at. It will just take few seconds to copy the link in browser and pasting it here.

//