#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int MOD = 1e9 + 7;
const int N = 1e6 + 10;
int n;
ll k;
int eks[N];
int add(int a, int b){
if(a + b >= MOD)
return a + b - MOD;
return a + b;
}
int mult(int a, int b){
return (a * b) % MOD;
}
int rec(int x, ll y){
if(x == 0)
return 0;
if(y & 1ll)
return add(eks[x - 1], rec(x - 1, y / 2));
return rec(x - 1, y / 2);
}
int main(){
eks[0] = 1;
for(int i = 1; i < N; i++)
eks[i] = mult(eks[i - 1], 2);
cin >> n >> k;
k--;
cout << add(rec(n, k), 1) << "\n";
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
4180 KB |
Output is correct |
2 |
Correct |
6 ms |
4100 KB |
Output is correct |
3 |
Correct |
5 ms |
4180 KB |
Output is correct |
4 |
Correct |
6 ms |
4180 KB |
Output is correct |
5 |
Correct |
6 ms |
4140 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
4180 KB |
Output is correct |
2 |
Correct |
6 ms |
4100 KB |
Output is correct |
3 |
Correct |
5 ms |
4180 KB |
Output is correct |
4 |
Correct |
6 ms |
4180 KB |
Output is correct |
5 |
Correct |
6 ms |
4140 KB |
Output is correct |
6 |
Correct |
5 ms |
4180 KB |
Output is correct |
7 |
Correct |
5 ms |
4132 KB |
Output is correct |
8 |
Correct |
5 ms |
4180 KB |
Output is correct |
9 |
Correct |
6 ms |
4180 KB |
Output is correct |
10 |
Correct |
6 ms |
4180 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
6 ms |
4180 KB |
Output is correct |
2 |
Correct |
6 ms |
4100 KB |
Output is correct |
3 |
Correct |
5 ms |
4180 KB |
Output is correct |
4 |
Correct |
6 ms |
4180 KB |
Output is correct |
5 |
Correct |
6 ms |
4140 KB |
Output is correct |
6 |
Correct |
5 ms |
4180 KB |
Output is correct |
7 |
Correct |
5 ms |
4132 KB |
Output is correct |
8 |
Correct |
5 ms |
4180 KB |
Output is correct |
9 |
Correct |
6 ms |
4180 KB |
Output is correct |
10 |
Correct |
6 ms |
4180 KB |
Output is correct |
11 |
Correct |
6 ms |
4180 KB |
Output is correct |
12 |
Correct |
5 ms |
4308 KB |
Output is correct |
13 |
Correct |
6 ms |
4216 KB |
Output is correct |
14 |
Correct |
6 ms |
4180 KB |
Output is correct |
15 |
Correct |
7 ms |
4160 KB |
Output is correct |