占座位
先特判
设
当
当
但这样当
可以发现过程中最多只会递归到
最简单的做法是用
要是真不会用
Code:
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<map>
using namespace std;
#define LL long long
map<LL,LL>mp;
LL n, k;
LL f( LL x ) {
if( x < 2 * k + 2 ) return 1;
if(mp[x]) return mp[x];
return mp[x] = f(x/2) + f(x-x/2);
}
int main() {
cin >> n >> k;
if( !k ) {
cout << n;
return 0;
}
cout << f(n);
}