# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1099077 | vjudge1 | Rack (eJOI19_rack) | C++17 | 1 ms | 604 KiB |
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 int long long
const int MOD = 1e9 + 7;
int binpow(int a, int b){
if(!b) return 1;
else if(b % 2 == 0){
int x = binpow(a, b / 2);
return (x * x) % MOD;
}else{
int x = binpow(a, b / 2);
x = (x * x) % MOD;
return (x * a) % MOD;
}
}
signed main(){
int n, k; cin >> n >> k;
int cnt = 0;
int ans = 1;
int pp = binpow(2, n - 1) % MOD;
while(k > 1){
if (k % 2 == 0) {
k--;
ans += pp;
ans %= MOD;
}
k -= (k - 1) / 2;
pp = (pp * binpow(2, MOD - 2) % MOD) % MOD;
pp %= MOD;
}
cout << ans << endl;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |