이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
using namespace std;
using ll = long long;
const ll MOD = (1000000007);
template <typename T> ostream& operator<<(ostream& os, const vector<T>& vec){for (auto itr : vec){os << itr << " ";} return os;}
ll n,k;
ll ans;
ll fpow(ll b, ll p){
if(b == 0){return 0;}
if(p == 0){return 1;}
if(p == 1){return b;}
ll a = fpow(b, p/2)%MOD;
a = (a*a)%MOD;
if(p%2){a = (a*b)%MOD;}
return a%MOD;
}
void solve(){
cin >> n >> k;
ans = 0;
k--;
for(ll p=0; p<62; p++){
if((k>>p)&1){
ans = (ans+ fpow(2,n-p-1))%MOD;
}
}
cout << ans+1 << endl;
}
int main(){
ios_base::sync_with_stdio(false); cin.tie(NULL);
solve();
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |