답안 #399609

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
399609 2021-05-06T09:18:47 Z cadmiumsky Rack (eJOI19_rack) C++14
100 / 100
9 ms 8128 KB
#include <iostream>
#define mod 1000000007
#define int unsigned long long


using namespace std;

int p2[1000001];

int n;

static int getnum(int poz, int step, int val=0) {
  if(step==n)
    return val;
  if((n-step-1)<=63) {
    //cout << step << '\n';
    if(poz>=(1ULL<<(n-step-1))) {
      //cout << "ok\n";
      val=(val+p2[step])%mod;
      poz-=(1ULL<<(n-step-1));
    }
  }
  return getnum(poz,step+1,val);
}

signed main() {
  p2[0]=1;
  for(int i=1; i<=1000000; i++)
    p2[i]=((long long)p2[i-1]*2LL)%mod;
  int k;
  cin >> n >> k;
  cout << 1+getnum(k-1,0) <<'\n';
  return 0;
}




/*
 * 
 * 
 * uiateasb
 * 
 * abcd
 * gggabggd
 * 
 * 
 * T[i][j] == daca am i caractere din s (primele)
 *      si alte j din t, care ar fi lungimea
 * 
 * T[i][j] = max( max (T[i][j-1], T[i-1][j]) , 
 *                T[i-1][j-1] (daca ultimele doua sunt egale)
 *   agcda 
 * a xxxxx 
 * b xxxxx
 * c xxo
 *   ac
 * T[4][8]=3
 */ 
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 8012 KB Output is correct
2 Correct 8 ms 8012 KB Output is correct
3 Correct 8 ms 8012 KB Output is correct
4 Correct 9 ms 8012 KB Output is correct
5 Correct 8 ms 8012 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 8012 KB Output is correct
2 Correct 8 ms 8012 KB Output is correct
3 Correct 8 ms 8012 KB Output is correct
4 Correct 9 ms 8012 KB Output is correct
5 Correct 8 ms 8012 KB Output is correct
6 Correct 8 ms 8028 KB Output is correct
7 Correct 8 ms 8120 KB Output is correct
8 Correct 8 ms 8012 KB Output is correct
9 Correct 8 ms 8060 KB Output is correct
10 Correct 8 ms 8012 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 8 ms 8012 KB Output is correct
2 Correct 8 ms 8012 KB Output is correct
3 Correct 8 ms 8012 KB Output is correct
4 Correct 9 ms 8012 KB Output is correct
5 Correct 8 ms 8012 KB Output is correct
6 Correct 8 ms 8028 KB Output is correct
7 Correct 8 ms 8120 KB Output is correct
8 Correct 8 ms 8012 KB Output is correct
9 Correct 8 ms 8060 KB Output is correct
10 Correct 8 ms 8012 KB Output is correct
11 Correct 8 ms 8128 KB Output is correct
12 Correct 8 ms 8036 KB Output is correct
13 Correct 8 ms 8020 KB Output is correct
14 Correct 8 ms 8012 KB Output is correct
15 Correct 9 ms 8048 KB Output is correct