You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

27 lines
452 B

#include <bits/stdc++.h>
using namespace std;
int n, k;
//吃草的奶牛数
int ans = 0;
//最终将会有多少群奶牛在平静地吃草.注意是群!!!!不是只!!!!
void dfs(int sum) {
if (sum <= k || (sum - k) & 1) {
ans++;
return;
}
int y = (sum - k) / 2;
int x = (sum + k) / 2;
dfs(x);
dfs(y);
}
int main() {
cin >> n >> k;
dfs(n);
cout << ans << endl;
return 0;
}