bzoj 1621: [Usaco2008 Open]Roads Around The Farm分岔路口【dfs】

模拟就行……讲道理这个时间复杂度为啥是对的???

#include<iostream>
#include<cstdio>
using namespace std;
int k,n;
int dfs(int v)
{
    if(v<=k) 
        return 1;
    if((v-k)%2==0)
        return (dfs((v-k)/2)+dfs((v+k)/2));
    else 
        return 1;
}
int main()
{
    scanf("%d%d",&n,&k);
    printf("%lld",dfs(n));
    return 0;
}

猜你喜欢

转载自www.cnblogs.com/lokiii/p/8963359.html
今日推荐