写一下二叉树 推一下公式就出来了, 注意取模时的输出形式
#include#define mem(a, b) memset(a, b, sizeof(a))using namespace std;typedef long long LL;const int maxn = 1e6+5, INF = 0x7fffffff, MOD = 1e9+7;LL n, k;LL qp(LL a, LL b){ LL res = 1; while(b) { if(b & 1) res = res * a % MOD; a = a * a % MOD; b >>= 1; } return res;}int main(){ while(cin>> n >> k) { if(n == 0) { cout<< 0 <