This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define sp " "
#define endl "\n"
#define fileio() freopen("input.txt", "r", stdin), freopen("output.txt", "w", stdout)
#define fastio() cin.tie(0), ios_base::sync_with_stdio(0)
#define pb push_back
#define pii pair<int, int>
#define st first
#define nd second
#define N 200005
#define L(node) node * 2
#define R(node) node * 2 + 1
#define int long long
const int modulo = 1e9 + 7;
int n, arr[1];
int fe(int a, int b)
{
if (b == 0) return 1;
if (b % 2 == 1) return (b * fe(a, b - 1)) % modulo;
int tmp = fe(a, b / 2);
return (tmp * tmp) % modulo;
}
int f(int k, int level)
{
if (k == 1) return 1;
if (level >= 64 || k <= 0) return arr[1];
int odd = 0;
if (level <= 62 && k % ((long long)1<<level) == 1) odd = 1;
if (odd) return f(k, level + 1);
return (f(k - ((long long)1<<(level - 1)), level + 1) + ((long long)1<<(n - level))) % modulo;
}
int32_t main()
{
fastio();
int k;
cin>>n>>k;
cout<<f(k, 1)<<endl;
cerr<<"time taken : "<<(float)clock() / CLOCKS_PER_SEC<<" seconds\n";
}
Compilation message (stderr)
rack.cpp: In function 'long long int f(long long int, long long int)':
rack.cpp:30:41: warning: array subscript 1 is above array bounds of 'long long int [1]' [-Warray-bounds]
30 | if (level >= 64 || k <= 0) return arr[1];
| ~~~~~^
rack.cpp:17:8: note: while referencing 'arr'
17 | int n, arr[1];
| ^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |