Hi,↵
↵
Could someone help me out with this problem?↵
↵
[problem:1578E]↵
↵
[submission:137851418]↵
↵
Thanks~~~~~↵
#include <bits/stdc++.h>↵
using namespace std;↵
↵
#define fast_io ios::sync_with_stdio(false),cin.tie(0)↵
typedef long long ll;↵
↵
ll power2(int n)↵
{↵
ll ans=1;↵
for(int i=0;i<n;i++) ans*=2;↵
return ans;↵
}↵
↵
int main()↵
{↵
fast_io;↵
↵
int t;cin>>t;↵
while(t--)↵
{↵
int h,p;cin>>h>>p;↵
↵
ll cnt=0,r=1,nodes=power2(h)-1;↵
while(r<p)↵
{↵
nodes-=r,cnt++;↵
r*=2;↵
}↵
cnt+=(nodes-1)/p+1;↵
cout<<cnt<<"\n";↵
}↵
}↵
~~~~~↵
↵
↵
↵
Thanks↵
↵
EDIT: Pasted code
↵
Could someone help me out with this problem?↵
↵
[problem:1578E]↵
↵
[submission:137851418]↵
↵
#include <bits/stdc++.h>↵
using namespace std;↵
↵
#define fast_io ios::sync_with_stdio(false),cin.tie(0)↵
typedef long long ll;↵
↵
ll power2(int n)↵
{↵
ll ans=1;↵
for(int i=0;i<n;i++) ans*=2;↵
return ans;↵
}↵
↵
int main()↵
{↵
fast_io;↵
↵
int t;cin>>t;↵
while(t--)↵
{↵
int h,p;cin>>h>>p;↵
↵
ll cnt=0,r=1,nodes=power2(h)-1;↵
while(r<p)↵
{↵
nodes-=r,cnt++;↵
r*=2;↵
}↵
cnt+=(nodes-1)/p+1;↵
cout<<cnt<<"\n";↵
}↵
}↵
~~~~~↵
↵
↵
↵
Thanks↵
↵
EDIT: Pasted code