首页 > 代码库 > Dropping Balls

Dropping Balls

#include<bits/stdc++.h>

using namespace std;

int D, N;
int main() {
    while (scanf("%d%d", &D, &N)!=EOF) {
         int k = 1;
        for (int i = 0; i < D - 1; i++) {
            if (N % 2) {
                k = k * 2;
                N = (N + 1) / 2;
            } else {
                k = k * 2 + 1;
                N /= 2;
            }
        }
        printf("%d\n", k);
}
  }

  

Dropping Balls