ARITHSEQ - Arithmetic sequence

Given an arithmetic sequence a, a + d, a + 2*d, ..., a + n*d.

Request

Count the number of digit x appearing in the given sequence.

Input

- A line containing a, d, n, x.

Output

- The result found.

Example

Input:
10 5 2 0

Output:
2

Limitations

- 1 ≤ a, n ≤ 109.
- 1 ≤ d ≤ 20,000.


Được gửi lên bởi:AnhDQ
Ngày:2009-07-16
Thời gian chạy:0.100s-1s
Giới hạn mã nguồn:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Ngôn ngữ cho phép:Tất cả ngoại trừ: ERL GOSU JS-RHINO NODEJS PERL6 PYPY RUST SED VB.NET
Nguồn bài:Mr Tuan Khuc Anh - NTU (Singapore)

hide comments
2016-09-24 15:49:07
Code:
http://shink.in/HOcqx
© Spoj.com. All Rights Reserved. Spoj uses Sphere Engine™ © by Sphere Research Labs.