이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mp make_pair
#define pb push_back
using ll = long long;
using ld = long double;
void solve(int T);
void pre();
const int mxn = 1e6 + 5;
const int SQRT = 500;
const int LOG = 20;
const int inf = 1e18;
const int mod = 1e9 + 7;
const ld eps = 1e-9;
int32_t main(){
pre();
int tt = 1;
//cin>>tt;
for(int i = 1;i<=tt;i++)solve(i);
return 0;
}
int p[mxn+1];
void pre(){
#ifdef ONLINE_JUDGE
ios::sync_with_stdio(false);
cin.tie(0);
#endif
p[0] = 1;
for(int i = 1;i<=mxn;i++){
p[i] = (2 * p[i-1]) % mod;
}
}
void solve(int T){
int n,k;
cin>>n>>k;
int ans = 1;
for(int i = n-1;i>=0;i--){
if(k % 2 == 0){
ans += p[i];
ans %= mod;
}
else {
k++;
}
k /= 2;
}
cout<<ans<<endl;
}
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |
| # | Verdict | Execution time | Memory | Grader output |
|---|
| Fetching results... |