//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <random>
#include <chrono>
using namespace std;
#define int long long
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ss second
#define ff first
#define pb push_back
using ull = unsigned long long;
const int mod = 1e9 + 7;
int power(int a, int b){
if(b == 0) return 1;
if(b == 1) return a % mod;
if(b % 2 == 0){
int y = power(a, b / 2);
return y * y % mod;
}else return power(a, b - 1) * a % mod;
}
void solve()
{
int n, k; cin >> n >> k;
auto rec = [&](auto&& rec, int i, int j) -> int{
if(i == 0) return 1;
if(j % 2) return rec(rec, i - 1, j / 2 + 1);
else return (rec(rec, i - 1, j / 2) + power(2, i - 1)) % mod;
};
cout << rec(rec, n, k);
}
signed main() {
cin.tie(nullptr)->sync_with_stdio(false);
// freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
int t = 1; //cin >> t;
while(t--){
solve();
cout << endl;
}
return 0;
}
Compilation message (stderr)
rack.cpp: In function 'int main()':
rack.cpp:60:10: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
60 | freopen("output.txt", "w", stdout);
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |