EASYMATH - EASY MATH
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 ≤ 232
1 ≤ a ≤ 232
1 ≤ d ≤ 232
2 ≤ t ≤ 100
Example
Input: 3 1 10 2 2 20 100 3 3 100 1000 4 5 Output: 5 54 543
Also try the challenge version at EASYMATC
hide comments
Aman Kumar:
2012-05-10 11:32:42
inclusion exclusion :) |
|
Gaurav:
2012-04-24 06:30:12
@devil D could you please see my soln and tell why it is giving WA...
|
|
(Tjandra Satria Gunawan)(曾毅昆):
2012-04-24 06:30:12
Nice problem ;) |
|
Francky:
2012-04-24 06:30:12
Nice problem, tutorial edition is Euler001 ;-) Last edit: 2012-04-17 20:33:25 |
|
Devil D:
2012-04-24 06:30:12
Sorry again
|
|
mehmetin:
2012-04-24 06:30:12
m = 20 in the first test case. Last edit: 2012-04-17 12:59:19 |
|
Devil D:
2012-04-24 06:30:12
For the first test case the numbers are
|
|
Devil D:
2012-04-24 06:30:12
Sorry and thanks..
|
|
__AAA__:
2012-04-24 06:30:12
what is the purpose of a?
|
|
Ikhaduri:
2012-04-24 06:30:12
What's "a" for??? |
Added by: | Devil D |
Date: | 2012-04-17 |
Time limit: | 0.100s-1s |
Source limit: | 20000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Languages: | All except: ASM64 |
Resource: | Own |