이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <iostream>
#include <string>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstring>
using namespace std;
#define ll long long
#define ull unsigned ll
#define pb push_back
#define mpr make_pair
#define lb lower_bound
#define ld long double
#define ub upper_bound
ll n, k;
vector<ll> ast;
ll mod = 1e9 + 7;
ll rec(ll n, ll k) {
    if (n == 0) {
        return 1;
    } if (k % 2LL) {
        return rec(n - 1LL, (k + 1LL) / 2LL);
    }
    else {
        return (rec(n - 1LL, k / 2LL) + ast[n - 1]) % mod;
    }
}
void solve() {
    cin >> n >> k;
    vector<ll> x(n, 1);
    ast = x;
    for(int i = 1; i < n; i++) {
        ast[i] = (ast[i - 1] * 2) % mod;
    }
    cout << rec(n, k) << endl;
}
int main() {
    /*cout.setf(ios::fixed | ios::showpoint);
    cout.precision(6);*/
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    solve();
    return 0;
}
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... | 
| # | Verdict | Execution time | Memory | Grader output | 
|---|
| Fetching results... |