1840B - Binary Cafe - CodeForces Solution


math

Please click on ads to support us..

C++ Code:

/*कर्मण्येवाधिकारस्ते मा फलेषु कदाचन।
मा कर्मफलहेतुर्भूर्मा ते सङ्गोऽस्त्वकर्मणि॥
Karmanye vadhikaraste Ma Phaleshu Kadachana
Ma Karmaphalaheturbhurma Te Sangostvakarmani,
The meaning of the verse is :—
You have the right to work only but never to its fruits.
Let not the fruits of action be your motive, nor let your attachment be to
inaction*/
#include <bits/stdc++.h>
using namespace std;
#define pi (3.141592653589)
#define mod 1000000007
#define pb push_back
#define is insert
#define mp make_pair
#define ff first
#define ss second
#define all(x) x.begin(), x.end()
#define max3(a, b, c) max(c, max(a, b))
#define max4(a, b, c, d) max(d, max(c, max(a, b)))
#define min3(a, b, c) min(c, min(a, b))
#define min4(a, b, c, d) min(d, min(c, min(a, b)))
#define rfr(n) for(int i=n-1;i>=0;i--)
#define rep1(i,a,b) for(long long i=a;i<=b;i++)
#define fr(n) for(long long i=0;i<n;i++)
#define nesfr(x,y) for(long long i=0;i<x;i++)for(long long j=0;j<y;j++)
#define rep(i,a,b) for(long long i=a;i<b;i++)
#define fast ios_base::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
#define nl cout << 
 
#define vvi vector<vector<ll>>
#define vvc vector<vector<char>>
#define vvb vector<vector<bool>>
#define vb vector<bool>
#define vc vector<char>
const unsigned int M = 1000000007;
const int  N = 2e5 + 5 ;
int gcd(int a,int b){
if(b==0){
return a;
}
return gcd(b,a%b);
}
int lcm(int a, int b) {
return (a * b) / gcd(a, b);
}
static bool cmp(pair<ll,ll> a, pair<ll,ll> b)
{
return (a.first < b.first || (a.first==b.first && a.second > b.second )) ;
}
bool is_set(unsigned int number, int x)
{
return (number >> x) & 1;
}
bool isPowerOfTwo(unsigned int n)
 {
return n && !(n & (n - 1));
}
int countSetBits(int n)
{
int count = 0;
while (n)
{
n = n & (n - 1);
count++;
}
return count;
}
int fib(int n) {
int a = 0;
int b = 1;
for (int i = 0; i < n; i++) {
int tmp = a + b;
a = b;
b = tmp;
}
return a;
}
int parent[200005];
int sizes[200005];
void make_set(int n) {
rep(i,1,n+1){
parent[i] = i;
sizes[i] = 1;
}
}
int find_set(int v) {
if (v == parent[v])
return v;
return parent[v] = find_set(parent[v]);
}
void union_sets(int a, int b) {
 a = find_set(a);
b = find_set(b);
if (a != b) {
if (sizes[a] < sizes[b])
swap(a, b);
parent[b] = a;
sizes[a] += sizes[b];
 }
}
void solve()
{
    ll n,k;
    cin>>n>>k;
    ll mx;
    if(k>63){
        mx=INT64_MAX;
    }
    else{
        mx=pow(2,k);
    }
    cout<<min(n+1,mx)<<endl;

}
int main(){
fast;
ll t=1;
cin>>t;
while(t--)
{
solve();
}
return 0;
}


Comments

Submit
0 Comments
More Questions

1268. Search Suggestions System
841. Keys and Rooms
152. Maximum Product Subarray
337. House Robber III
869. Reordered Power of 2
1593C - Save More Mice
1217. Minimum Cost to Move Chips to The Same Position
347. Top K Frequent Elements
1503. Last Moment Before All Ants Fall Out of a Plank
430. Flatten a Multilevel Doubly Linked List
1290. Convert Binary Number in a Linked List to Integer
1525. Number of Good Ways to Split a String
72. Edit Distance
563. Binary Tree Tilt
1306. Jump Game III
236. Lowest Common Ancestor of a Binary Tree
790. Domino and Tromino Tiling
878. Nth Magical Number
2099. Find Subsequence of Length K With the Largest Sum
1608A - Find Array
416. Partition Equal Subset Sum
1446. Consecutive Characters
1618A - Polycarp and Sums of Subsequences
1618B - Missing Bigram
938. Range Sum of BST
147. Insertion Sort List
310. Minimum Height Trees
2110. Number of Smooth Descent Periods of a Stock
2109. Adding Spaces to a String
2108. Find First Palindromic String in the Array