Message on Whatsapp 8879355057 for DSA(OA + Interview) + Fullstack Dev Training + 1-1 Personalized Mentoring to get 10+LPA Job
0 like 0 dislike
1,243 views

Bonus : Best Image2Pdf feature is here : https://www.desiqna.in/image2pdf/

All past online assesments of Walmart can be found using the tag "walmart_oa" in the search bar.

Here is the link :  https://www.desiqna.in/tag/walmart_oa

in Online Assessments by Expert (4,460 points) | 1,243 views

1 Answer

0 like 0 dislike

Walmart Online Assessment Questions and Solutions.

 

by Expert (4,460 points)
0 0
#include <bits/stdc++.h>
using namespace std;
#define int long long
int binpow(int x,int n)
{
    if(n==1)
    return x;
    if(n==0)
    return 1;
    int ans=binpow(x,n/2);
    if(n%2)
    return ans*ans*x;
    return ans*ans;
}
int32_t main() {
     int x,n;
     cin>>x>>n;
     int y=0;
     while((x*(binpow(x,y)-1))/(x-1)<=n)
         y++;
     y--;
     int t1=(binpow(x,y)-1)/(x-1);int t2=0;
     if((n-t1*x)%x==0)
     t2=(n-t1*x)/x;
     else
     t2=(n-t1*x)/x+1;
     cout<<t1+t2<<endl;
     
}