Responsive image

问题 1895 --Function Counting

1895: Function Counting

时间限制: 4 Sec  内存限制: 128 MB
提交: 1  解决: 1
[提交][状态][讨论版][命题人:]

题目描述

In this problem, we count the number of function f(x) satisfies below details.
1.f: M→M, ( M={-n,-n+1,-n+2,…,-1,0,1,…,n} ) 
2.∀x∈M,fk(x)=−x,(f0(x)=x,fi=f(fi−1)(i=1,2,…))
3.∀x∈M,|(|f(x)|−|x|)|≤2
 

输入描述

The first line of input contains an integer T (1 <= T <= 100) , the number of test cases.
Each test case contains a pair of integers n, k (n * k <= 10^9), the upper limit of the set M and degree of f.
The total sum of n * k over all test cases does not exceed 4e9.
 

输出描述

For each test case output the answer % 1000000007.
 

样例输入

7
1 1
2 1
100 1
1 2
2 2 
3 2
20 4

样例输出

1
1
1
0
2
0
1048576

提示

If k = 1, only one function f(x) = -x exists.
If n = k = 2, two functions exist. f: (-2, -1, 0, 1, 2) -> (1, -2, 0, 2, -1) or (-1, 2, 0, -2, 1).

来源

 

[提交][状态]
ACM算法攻关部
  • Anything about this OnlineJudge, Please Contact Administrator. Click add QQ

    OJ system based on HUSTOJ Project , UI based on Twitter Bootstrap

    Copyright 2016 ACM算法攻关部
    关于网站改版