#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int nx=1e6+5, mod=1e9+7;
ll n, k, res, p[nx];
int main()
{
cin.tie(NULL)->sync_with_stdio(false);
p[0]=1;
for (int i=1; i<nx; i++) p[i]=(p[i-1]*2)%mod;
cin>>n>>k;
for (int i=n-1; i>=0; i--)
{
if (k%2==0) res=(res+p[i])%mod;
k=(k+1)/2;
}
cout<<(res+k)%mod;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
8024 KB |
Output is correct |
2 |
Correct |
5 ms |
8028 KB |
Output is correct |
3 |
Correct |
6 ms |
8080 KB |
Output is correct |
4 |
Correct |
5 ms |
8024 KB |
Output is correct |
5 |
Correct |
5 ms |
8028 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
8024 KB |
Output is correct |
2 |
Correct |
5 ms |
8028 KB |
Output is correct |
3 |
Correct |
6 ms |
8080 KB |
Output is correct |
4 |
Correct |
5 ms |
8024 KB |
Output is correct |
5 |
Correct |
5 ms |
8028 KB |
Output is correct |
6 |
Correct |
5 ms |
8284 KB |
Output is correct |
7 |
Correct |
5 ms |
8284 KB |
Output is correct |
8 |
Correct |
5 ms |
8284 KB |
Output is correct |
9 |
Correct |
5 ms |
8028 KB |
Output is correct |
10 |
Correct |
5 ms |
8280 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
5 ms |
8024 KB |
Output is correct |
2 |
Correct |
5 ms |
8028 KB |
Output is correct |
3 |
Correct |
6 ms |
8080 KB |
Output is correct |
4 |
Correct |
5 ms |
8024 KB |
Output is correct |
5 |
Correct |
5 ms |
8028 KB |
Output is correct |
6 |
Correct |
5 ms |
8284 KB |
Output is correct |
7 |
Correct |
5 ms |
8284 KB |
Output is correct |
8 |
Correct |
5 ms |
8284 KB |
Output is correct |
9 |
Correct |
5 ms |
8028 KB |
Output is correct |
10 |
Correct |
5 ms |
8280 KB |
Output is correct |
11 |
Correct |
5 ms |
8028 KB |
Output is correct |
12 |
Correct |
6 ms |
8284 KB |
Output is correct |
13 |
Correct |
6 ms |
8284 KB |
Output is correct |
14 |
Correct |
6 ms |
8068 KB |
Output is correct |
15 |
Correct |
7 ms |
8284 KB |
Output is correct |