|
||||||||||
K-th Nya NumberTime Limit: 2000/1000 MS (Java/Others) Memory Limit: 125536/65536 K (Java/Others)Total Submission(s): 3921 Accepted Submission(s): 1266 Problem Description Arcueid likes nya number very much. A nya number is the number which has exactly X fours and Y sevens(If X=2 and Y=3 , 172441277 and 47770142 are nya numbers.But 14777 is not a nya number ,because it has only 1 four). Now, Arcueid wants to know the K-th nya number which is greater than P and not greater than Q. Input The first line contains a positive integer T (T<=100), indicates there are T test cases. The second line contains 4 non-negative integers: P,Q,X and Y separated by spaces. ( 0<=X+Y<=20 , 0< P<=Q <2^63) The third line contains an integer N(1<=N<=100). Then here comes N queries. Each of them contains an integer K_i (0<K_i <2^63). Output For each test case, display its case number and then print N lines. For each query, output a line contains an integer number, representing the K_i-th nya number in (P,Q]. If there is no such number,please output "Nya!"(without the quotes). Sample Input
Sample Output
Author hzhua Source | ||||||||||
|