이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl '\n'
#define FF first
#define SS second
#define all(a) a.begin(), a.end()
#define mod (ll)(1000000007)
int add(ll a, ll b) {
ll res = a + b;
return res % mod;
}
int mul(ll a, ll b) {
a %= mod, b %= mod;
ll res = a * b;
return res % mod;
}
int main() {
ios_base::sync_with_stdio(0);
cin.tie(0);
ll n, k;
cin >> n >> k;
vector<int> Pwr_of_two(n+1);
Pwr_of_two.front() = 1;
for (int i = 1; i <= n; i++) {
Pwr_of_two[i] = mul(Pwr_of_two[i - 1], 2);
}
ll ans = 1;
for (int i = n - 1; i >= 0; i--) {
if (k % 2 == 0) {
ans = add(ans, Pwr_of_two[i]);
}
k = (k + 1) / 2;
}
cout << ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |