이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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
*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |