제출 #1143498

#제출 시각아이디문제언어결과실행 시간메모리
1143498fryingducRack (eJOI19_rack)C++20
40 / 100
4 ms4308 KiB
#include "bits/stdc++.h"
using namespace std;

#ifdef duc_debug
#include "bits/debug.h"
#else
#define debug(...)
#endif

const int maxn = 1e6 + 6;
const int mod = 1e9 + 7;
int n, k, p[maxn];

int calc(int n, int k) {
  if(n == 0) {
    return k;
  }
  int ans = calc(n - 1, (k + 1) / 2);
  if(k % 2 == 0) {
    ans += p[n - 1];
    if(ans >= mod) ans -= mod;
  }
  return ans;
}

void solve() {
  cin >> n >> k;
  cout << calc(n, k);
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  p[0] = 1;
  for(int i = 1; i < maxn; ++i) {
    p[i] = p[i - 1] + p[i - 1];
    if(p[i] >= mod) {
      p[i] -= mod;
    }
  }

  solve();

  return 0;
}


#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...