CSES Solutions
#1617Introductory Problems

Bit Strings

View on CSES

Solution

1617-Bit_Strings.cpp
1#include<bits/stdc++.h>
2using namespace std;
3#define int long long
4const int m=1e9+7;
5signed main(){
6  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
7  int n; cin>>n;
8  int a=2,ans=1;
9  while(n){
10    if(n&1) ans=ans*a%m;
11    a=a*a%m,n>>=1;
12  }
13  cout<<ans<<'\n';
14  return 0;
15}

Editorial not yet generated for this problem. Run the editorial generation script to add hints and detailed explanations.