Submit | All submissions | Best solutions | Back to list |
ARITHSEQ - Arithmetic sequence |
English | Tiếng Việt |
Cho cấp số cộng a, a + d, a + 2*d, ..., a + n*d.
Yêu cầu
Hãy đếm xem chữ số x xuất hiện bao nhiêu lần ở dãy số này.
Dữ liệu
- Gồm một dòng duy nhất chứa bốn số a, d, n, x.
Kết quả
- Gồm một số duy nhất là kết quả của bài toán.
Ví dụ
Dữ liệu: 10 5 2 0 Kết quả: 2
Giới hạn
- 1 ≤ a, n ≤ 109.
- 1 ≤ d ≤ 20,000.
Added by: | AnhDQ |
Date: | 2009-07-16 |
Time limit: | 0.100s-1s |
Source limit: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ERL JS-RHINO NODEJS PERL6 VB.NET |
Resource: | Mr Tuan Khuc Anh - NTU (Singapore) |
hide comments
2016-07-27 15:05:24
Why there is a TLE error given by using C ? |
|
2013-07-02 14:35:01 sriankit
what will be ans for 5 5 3 0 2 or 3?? EDIT : ans is 2 Last edit: 2013-07-02 20:14:35 |
|
2010-12-30 06:20:17 :D
It's five. Why would it be one? |
|
2010-12-29 19:23:52 saibharath
I HAVE A DOUBT. IF INPUT IS 20 1 3 2 WHAT MUST BE THE ANSWER. IT MUST BE 1 OR 5 |
|
2009-07-19 14:18:42 Karpovych Artem
How many test cases in this problem? Only one? Re: as the problem said, input contains "a line", so it contains only one single test case :-) Last edit: 2009-07-23 14:41:22 |
|
2009-07-17 12:04:41 Vaibhav
Hi, are we supposed to return the first location of the digit x? This is what I understand: Sequence: 101520, x=0, first occurence of x is 2nd position, hence answer is 2. Is this right? Re: "the number of.." means the "amount", for example, x=0 appears twice in the arithmetic sequence: 20 25 30 (a=20,d=5,n=2,x=0) ;-) Last edit: 2009-07-17 14:54:03 |
|
2009-07-17 03:42:33 piyifan
Can x>9 or x<0? Re: x is a "digit", so x = 0..9 Last edit: 2009-07-17 05:52:22 |