# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
761211 | KN200711 | Rack (eJOI19_rack) | C++14 | 2 ms | 304 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>
# define ll long long
using namespace std;
const ll MOD = 1e9 + 7;
ll fast(ll a, ll b) {
if(b == 0) return 1ll;
if(b == 1) return a;
ll K = fast(a, b/2ll);
K *= K;
K %= MOD;
if(b&1) {
K *= a;
K %= MOD;
}
return K;
}
ll add(ll a, ll b) {
a += b;
a %= MOD;
return a;
}
int main() {
ll N, K;
scanf("%lld %lld", &N, &K);
ll ans = 0ll;
for(int i=N;i>=1;i--) {
if(i == 1) {
if(K&1) ans = add(ans, 1ll);
else ans = add(ans, 2ll);
} else {
if(K&1) {
} else {
ans = add(ans, fast(2ll, 1ll * i - 1ll));
}
}
K = (K + 1ll) / 2ll;
}
printf("%lld\n", ans);
return 0;
}
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... |