EASYMATC - EASY MATH (Challenge)
You will be given 4 numbers: n m a d.
find count of numbers between n and m (inclusive) not divisible by (a) or (a+d) or (a+2d) or (a+3d) or (a+4d).
Input
first line has number t - number of test cases.
each test case has 4 numbers n m a d.
Output
Single line having single number giving the count.
Constraints
1 <= n <= m <= 2^32
1 <= a <= 2^32
1 <= d <= 2^32
2 <= t <= 100
Example
Input: 3 1 10 2 2 20 100 3 3 100 1000 4 5 Output: 5 54 543
hide comments
parth_arora02:
2024-04-16 15:33:54
<snip>
|
|
paulpascal:
2016-12-27 14:07:48
TLE in C++ |
|
Sanjay Singh:
2014-06-06 12:03:49
its working for n<=10^7.but above that showing TLE |
|
pvkcse:
2014-05-16 23:18:42
also TLE in python 3.2.3 |
|
Mitch Schwartz:
2014-04-24 15:37:47
@Nadav Chernin: Problem description and example are fine. We have S = {a, a+d, ... , a+4d} and the predicate on integer x in [n,m] is: there does not exist s in S such that s divides x. |
|
nadavishe:
2014-04-24 12:20:23
Something wrong in problem definition
|
|
Aditya Pande:
2012-10-06 19:34:42
its not the language but its your naive algorithm |
|
Bharath Reddy:
2012-07-08 10:36:35
TLE in Perl.. |
Added by: | Devil D |
Date: | 2012-04-23 |
Time limit: | 1s |
Source limit: | 3000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | own |