一场游戏一场空,最终 最初都由我掌控,好像一身从容,不曾有狼狈伤痛,可深夜一个人该如何相拥?
This night wasn't easy on Vasya. His favorite team lost, and he didn't find himself victorious either — although he played perfectly, his teammates let him down every time. He had to win at least one more time, but the losestreak only grew longer and longer... It's no wonder he didn't get any sleep this night at all.
In the morning, Vasya was waiting the bus to the university on the bus stop. Vasya's thoughts were hazy and so he couldn't remember the right bus' number quite right and got onto the bus with the number nn.
In the bus, Vasya thought that he could get the order of the digits in the number of the bus wrong. Futhermore, he could "see" some digits several times, but the digits he saw were definitely in the real number of the bus. For example, if Vasya saw the number 2028, it could mean that the real bus number could be 2028, 8022, 2820 or just 820. However, numbers 80, 22208, 52 definitely couldn't be the number of the bus. Also, real bus number couldn't start with the digit 0, this meaning that, for example, number 082 couldn't be the real bus number too.
Given nn, determine the total number of possible bus number variants.
Input
The first line contains one integer nn (1≤n≤10181≤n≤1018) — the number of the bus that was seen by Vasya. It is guaranteed that this number does not start with 00.
Output
Output a single integer — the amount of possible variants of the real bus number.
Examples
input
Copy
97
output
Copy
2
input
Copy
2028
output
Copy
13
Note
In the first sample, only variants 9797 and 7979 are possible.
In the second sample, the variants (in the increasing order) are the following: 208208, 280280, 802802, 820820, 20282028, 20822082, 22082208, 22802280, 28022802, 28202820, 80228022, 82028202, 8220
#include
#include #include #include #include #include #include #include #include #include #include There were nn types of swords in the theater basement which had been used during the plays. Moreover there were exactly xx swords of each type. yy people have broken into the theater basement and each of them has taken exactly zz swords of some single type. Note that different people might have taken different types of swords. Note that the values x,yx,y and zzare unknown for you.
The next morning the director of the theater discovers the loss. He counts all swords — exactly aiai swords of the ii-th type are left untouched.
The director has no clue about the initial number of swords of each type in the basement, the number of people who have broken into the basement and how many swords each of them have taken.
For example, if n=3n=3, a=[3,12,6]a=[3,12,6] then one of the possible situations is x=12x=12, y=5y=5and z=3z=3. Then the first three people took swords of the first type and the other two people took swords of the third type. Note that you don't know values x,yx,y and zz beforehand but know values of nn and aa.
Thus he seeks for your help. Determine the minimum number of people yy, which could have broken into the theater basement, and the number of swords zz each of them has taken.
Input
The first line of the input contains one integer nn (2≤n≤2⋅105)(2≤n≤2⋅105) — the number of types of swords.
The second line of the input contains the sequence a1,a2,…,ana1,a2,…,an (0≤ai≤109)(0≤ai≤109), where aiai equals to the number of swords of the ii-th type, which have remained in the basement after the theft. It is guaranteed that there exists at least one such pair of indices (j,k)(j,k) that aj≠akaj≠ak.
Output
Print two integers yy and zz — the minimum number of people which could have broken into the basement and the number of swords each of them has taken.
Examples
input
Copy
3 3 12 6
output
Copy
5 3
input
Copy
2 2 9
output
Copy
1 7
input
Copy
7 2 1000000000 4 6 8 4 2
output
Copy
2999999987 2
input
Copy
6 13 52 0 13 26 52
output
Copy
12 13
Note
In the first example the minimum value of yy equals to 55, i.e. the minimum number of people who could have broken into the basement, is 55. Each of them has taken 33 swords: three of them have taken 33 swords of the first type, and two others have taken 33 swords of the third type.
In the second example the minimum value of yy is 11, i.e. the minimum number of people who could have broken into the basement, equals to 11. He has taken 77 swords of the first type.
#include
#include #include #include #include #include #include #include #include #include #include Nastya received one more array on her birthday, this array can be used to play a traditional Byteland game on it. However, to play the game the players should first select such a subsegment of the array that , where p is the product of all integers on the given array, s is their sum, and k is a given constant for all subsegments.
Nastya wonders how many subsegments of the array fit the described conditions. A subsegment of an array is several consecutive integers of the array.
Input
The first line contains two integers n and k (1 ≤ n ≤ 2·105, 1 ≤ k ≤ 105), where n is the length of the array and k is the constant described above.
The second line contains n integers a1, a2, ..., an (1 ≤ ai ≤ 108) — the elements of the array.
Output
In the only line print the number of subsegments such that the ratio between the product and the sum on them is equal to k.
Examples
input
Copy
1 1 1
output
Copy
1
input
Copy
4 2 6 3 8 1
output
Copy
2
Note
In the first example the only subsegment is [1]. The sum equals 1, the product equals 1, so it suits us because .
There are two suitable subsegments in the second example — [6, 3] and [3, 8, 1]. Subsegment [6, 3] has sum 9 and product 18, so it suits us because . Subsegment [3, 8, 1] has sum 12 and product 24, so it suits us because .
#include
#include #include #include #include #include #include #include #include #include #include