No data type can store such large number. Using array
int a[pow(10,pow(10,18))]
again won't do the job because pow()
returns double
and double
can't store 10^(10^18)
.
Anyone having any idea?
I'm trying to solve the following problem:
Consider an integer with N digits (in decimal notation, without leading zeroes) D1,D2,D3,…,DN. Here, D1 is the most significant digit and DN the least significant. The weight of this integer is defined as:
∑ i=2 -> N (Di−Di−1).
You are given integers N and W. Find the number of positive integers with N digits (without leading zeroes) and weight equal to W. Compute this number modulo 109+7.
Input:
The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows. The first and only line of each test case contains two space-separated integers N and W denoting the number of digits and the required weight.
Output:
For each test case, print a single line containing one integer — the number of N-digit positive integers with weight W, modulo 109+7.
Constraints:
- 1≤T≤105
- 2≤N≤1018
- |W|≤300