P15450 [GeeksforGeeks] Decimal equivalent of binary linked list
普及-
题目描述

Given a singly linked list of 0s and 1s, the task is to find its decimal equivalent. Decimal Value of an empty linked list is considered as 0.
Since the answer can be very large, answer modulo 1000000007 should be printed.
Input:
First line of input contains number of testcases T. For each testcase, first line of input contains
Output:
The function should return should decimal equivalent modulo 1000000007.
User Task:
The task is to complete the function decimalValue() which should find the decimal value of the given binary value in the linked list.
Constraints:
1 <= T <= 200
0 <= N <= 100
Data of Node is either 0 or 1
Example:
Input:
2
3
0 1 1
4
1 1 1 0
Output:
3
14
Explanation:
Testcase 1: 12^{0} + 12^{1} + 0*2^{2} = 1 + 2 + 0 = 3.

输入格式

见题面

输出格式

见题面

样例输入
2 3 0 1 1 4 1 1 1 0
样例输出
3 14