#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
int am = 0;
ll binpow(ll a, ll b){
ll res = 1;
if (b == -1){
return 0;
}
while (b != 0){
if (b % 2 == 0){
b /= 2;
a *= a;
if (a >= mod){
am++;
}
a %= mod;
}
else{
b -= 1;
res *= a;
if (res >= mod){
am++;
}
res %= mod;
}
}
return res;
}
vector<vector<ll>> ve;
ll ans = 1;
ll f(ll n, ll k, ll va){
ll val = 0;
if (n == 0){
return 0;
}
am = 0;
ll po = binpow(2, n - 1);
if (n <= 63){
ll op = pow(2, n - 1);
if (k >= op){
val += binpow(2, va);
ve.push_back({n - 1, k - op, va + 1});
ans += val;
return 0;
}
}
ve.push_back({n - 1, k, va + 1});
ans += val;
return 0;
}
int main(){
ll n, k;
cin>>n>>k;
k--;
ve.push_back({n, k, 0});
for (int i = 0; i < ve.size(); i++){
f(ve[i][0], ve[i][1], ve[i][2]);
ans %= mod;
}
cout<<ans;
}
Compilation message
rack.cpp: In function 'long long int f(long long int, long long int, long long int)':
rack.cpp:39:8: warning: unused variable 'po' [-Wunused-variable]
39 | ll po = binpow(2, n - 1);
| ^~
rack.cpp: In function 'int main()':
rack.cpp:59:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
59 | for (int i = 0; i < ve.size(); i++){
| ~~^~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
600 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
600 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
436 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
0 ms |
348 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Correct |
0 ms |
600 KB |
Output is correct |
4 |
Correct |
0 ms |
348 KB |
Output is correct |
5 |
Correct |
1 ms |
348 KB |
Output is correct |
6 |
Correct |
1 ms |
344 KB |
Output is correct |
7 |
Correct |
0 ms |
436 KB |
Output is correct |
8 |
Correct |
0 ms |
348 KB |
Output is correct |
9 |
Correct |
0 ms |
348 KB |
Output is correct |
10 |
Correct |
0 ms |
348 KB |
Output is correct |
11 |
Correct |
1 ms |
368 KB |
Output is correct |
12 |
Correct |
1 ms |
348 KB |
Output is correct |
13 |
Correct |
1 ms |
604 KB |
Output is correct |
14 |
Correct |
8 ms |
3344 KB |
Output is correct |
15 |
Correct |
145 ms |
53992 KB |
Output is correct |