이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#define int long long
#define sz(a) (int)a.size()
#define all(x) (x).begin(), (x).end()
using namespace std;
const int mod=1e9+7;
int MOD(int x){
return ((x+mod)%mod);
}
int fast_pow(int x, int p){
if(p==1) return x;
if(p==0) return 1;
if(p%2==0) return MOD(MOD(fast_pow(x,p/2))*MOD(fast_pow(x,p/2)));
else return MOD(MOD(fast_pow(x,p-1))*x);
}
signed main() {
ios_base::sync_with_stdio(false); cin.tie(nullptr);
int n,k; cin >> n>>k;
k--;
int sum=1;
for (int i = 1; i <= n; i++)
{
if(k&(1LL<<(i-1LL))) sum=MOD(sum+MOD(fast_pow(2LL, (n-i))));
}
cout << sum << "\n";
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |