ITGUY11 - Editorial

Problem: https://www.codechef.com/PBK02020/problems/ITGUY11

DIFFICULTY:

EASY.

PROBLEM:

For Diwali, Chef arranges all KK laddus in a row in his sweet shop. Whenever a customer comes to buy laddus, chef follows a rule that each customer must buy all laddus on odd position. After the selection of the laddu, a new row is formed, and again out of these only laddus on odd position are selected. This continues until the chef left with the last laddu. Find out the position of that last laddu in the original row.

Program:

#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
int t;
cin>>t;
while(t–){
int n;
cin>>n;
int mp=0;
while(n>0){
mp++;
n/=2;
}
mp=pow(2,mp-1);
cout<<mp<<"\n";
}
return 0;
}

Hey @references can you please reschedule tomorrow’s push_back(1) contest a little bit as it is clashing with the codeforces Educational round scheduled tomorrow at the same time.

1 Like

Thanks… Time is updated now