EASYMATH  EASY MATH
You will be given 4 numbers
n m a d
find count of numbers between n & 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
Example
Input: 3
1 10 2 2
20 100 3 3
100 1000 4 5 Output:
5
54
543
NOTE  1<=n<=m<= 2^32
1<=a<= 2^32
1<=d<=2^32
2<=t<=100
ALSO TRY THR CHALLENGE VERSION  /http://www.spoj.com/problems/EASYMATC/
hide comments
abdo_farah:
20200621 07:01:30
OMG, it is all about Math.


siddhantj19:
20200617 21:33:30
AC. YAY. Inclusion exclusion saved this


adityaguptagkp:
20200501 11:28:10
can anyone give a hint


meryx:
20191101 01:09:19
I keep getting TLE :(


hrittik16:
20190620 15:08:47
Find the pattern between inclusion exclusion formula and subsets of a set. Then implement it 

rexx:
20181016 19:58:30
very nice problem :) 

darkknight21:
20180910 19:09:01
solvable using inclusionexclusion principle take care of implementation 

dunjen_master:
20170901 00:29:27
tle by iteration.. 

kejriwal:
20160201 12:05:01
easy math :) 

syukri:
20151029 06:02:54
got TLE :) 
Added by:  Devil D 
Date:  20120417 
Time limit:  0.100s1s 
Source limit:  20000B 
Memory limit:  1536MB 
Cluster:  Cube (Intel G860) 
Languages:  All except: ASM64 
Resource:  Own 