4283: Masha and geometric depression玛莎和几何凹陷

内存限制:256 MB 时间限制:1 S 标准输入输出
题目类型:传统 评测方式:文本比较 上传者:
提交:4 通过:4

题目描述

    玛莎真的很喜欢代数。在最后一堂课上,她严厉的老师德瓦斯坦给了她新的练习。
    你得到由两个整数定义的几何级数 b
b1。提醒几何级数是整数序列b1b2b3,...,其中对于每个 i>1 各自的项满足条件b=bI-1·q,其中 q 称为级数的公共比率。乌日良迪亚的进展是不寻常的:两者都b1并且 q 可以等于 0。此外,德瓦斯坦给了玛莎 m “坏”整数一个1a2,...,am和整数 l
    玛莎将所有进度项一一写到黑板上(包括重复),而条件
|bi|≤l满意 (|x|表示 x 的绝对值)。有一个例外:如果一个术语等于其中一个“坏”整数,Masha 会跳过它(不会写到板上)并前进到下一个术语。
    但是这节课很快就要结束了,所以玛莎必须计算黑板上会写多少个整数。为了不陷入抑郁,玛莎向你求助:帮她计算她会写多少个数字,或者打印“inf”以防她需要写无限多个整数。
    Masha really loves algebra. On the last lesson, her strict teacher Dvastan gave she new exercise.
    You are given geometric progression b defined by two integers b1 and q. Remind that a geometric progression is a sequence of integers b1,b2,b3,..., where for each i>1 the respective term satisfies the condition bi=bi-1·q, where q is called the common ratio of the progression. Progressions in Uzhlyandia are unusual: both b1 and q can equal 0. Also, Dvastan gave Masha m "bad" integers a1,a2,...,am, and an integer l.
    Masha writes all progression terms one by one onto the board (including repetitive) while condition |bi|≤l is satisfied (|x| means absolute value of x). There is an exception: if a term equals one of the "bad" integers, Masha skips it (doesn't write onto the board) and moves forward to the next term.
    But the lesson is going to end soon, so Masha has to calculate how many integers will be written on the board. In order not to get into depression, Masha asked you for help: help her calculate how many numbers she will write, or print "inf" in case she needs to write infinitely many integers.
Input
The first line of input contains four integers b1, q, l, m (-109b1,q≤109, 1≤l≤109, 1≤m≤105)− the initial term and the common ratio of progression, absolute value of maximal number that can be written on the board and the number of "bad" integers, respectively.
The second line contains m distinct integers a1,a2,...,am (-109ai≤109)− numbers that will never be written on the board.
Output
Print the only integer, meaning the number of progression terms that will be written on the board if it is finite, or "inf" (without quotes) otherwise.
Examples
Input
3 2 30 4
6 14 25 48
Output
3
Input
123 1 2143435 4
123 11 -5453 141245
Output
0
Input
123 1 2143435 4
54343 -13 6 124
Output
inf
Note
In the first sample case, Masha will write integers 3,12,24. Progression term 6 will be skipped because it is a "bad" integer. Terms bigger than 24 won't be written because they exceed l by absolute value.
In the second case, Masha won't write any number because all terms are equal 123 and this is a "bad" integer.
In the third case, Masha will write infinitely integers 123.

输入格式

输入
输入的第一行包含四个整数b1, q, l, m (-109b1Q≤109,1≤l≤109,1≤ m105)− 初始项和级数的共同比率,可以写在板上的最大数的绝对值和“坏”整数的数量。
第二行包含 m 个不同的整数
一个1a2,...,am (-109a≤109)−永远不会写在黑板上的数字。

输出格式

输出
打印唯一的整数,即如果它是有限的,则将写入板上的级数项数,否则为“inf”(不带引号)。
例子
输入
3 2 30 4
6 14 25 48
输出
3
输入
123 1 2143435 4
123 11 -5453 141245
输出
0
输入
123 1 2143435 4
54343 -13 6 124
输出
inf
注意
在第一种示例情况下,Masha 将写入整数 3,12,24。级数项 6 将被跳过,因为它是一个“坏”整数。大于 24 的项不会被写入,因为它们的绝对值超过 l
在第二种情况下,Masha 不会写任何数字,因为所有项都等于 123,这是一个“坏”整数。
在第三种情况下,玛莎将无限写出整数 123


输入样例 复制

3 2 30 4
6 14 25 48

输出样例 复制

3