CodeForces 992D Nastya and a Game 思维

D. Nastya and a Game
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

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·1051 ≤ 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 .


前辈大神真真是四国以内!之前我都没有意识要这么利用题目给的数据范围。。。总之,对于1这样的值,对积没有影响,对和确实单调递增,遇到直接跳过,判断区间两端的值是否符合要求即可;而根据计算,2e18是积的最大值,每个用于乘积的值又至少是2,六十几次内,必定结束一次有确定起点的区间的循环。太厉害了!


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值