F.A.Q
Hand In Hand
Online Acmers
Problem Archive
Realtime Judge Status
Authors Ranklist
 
     C/C++/Java Exams     
ACM Steps
Go to Job
Contest LiveCast
ICPC@China
Best Coder beta
VIP | STD Contests
    DIY | Web-DIY beta
Author ID 
Password 
 Register new ID

Function Counting

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 153428/153428 K (Java/Others)
Total Submission(s): 142    Accepted Submission(s): 65


Problem Description
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.$\forall x¡ÊM, f_k (x)= -x,( f_0 (x)=x,f_i= f(f_{i-1} ) (i= 1,2,¡­) )$
3.$\forall x¡ÊM, |(|f(x)|-|x|)|¡Ü2$
 

Input
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.
 

Output
For each test case output the answer % 1000000007.
 

Sample Input
7 1 1 2 1 100 1 1 2 2 2 3 2 20 4
 

Sample Output
1 1 1 0 2 0 1048576
 

Hint

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).
 

Source
 

Statistic | Submit | Discuss | Note
Hangzhou Dianzi University Online Judge 3.0
Copyright © 2005-2024 HDU ACM Team. All Rights Reserved.
Designer & Developer : Wang Rongtao LinLe GaoJie GanLu
Total 0.000000(s) query 1, Server time : 2024-11-22 17:46:25, Gzip enabled