Last Digit Sum

All submissions for this problem are available.
For a nonnegative integer N, define S(N) as the sum of the odd digits of N
plus twice the sum of the even digits of N.
For example, S(5)=5, S(456)=2*4+5+2*6=25, and S(314159)=3+1+2*4+1+5+9=27.
Define D(N) as the last digit of S(N).
So D(5)=5, D(456)=5, and D(314159)=7.
Given 2 nonnegative integers A and B, compute the sum of D(N) over all N between A and B, inclusive.
Input
Input will begin with an integer T, the number of test cases.
T lines follow, each containing 2 integers A and B.
Output
For each test case, output a single integer indicating the corresponding sum.
Sample Input
3 1 8 28 138 314159 314159
Sample Output
36 495 7
Constraints
 T ≤ 1000
 0 ≤ A ≤ B ≤ 400,000,000
Author:  pieguy 
Tester:  chmel_tolstiy 
Editorial  http://discuss.codechef.com/problems/LASTDIG 
Tags  cook14 easy pieguy 
Date Added:  2092011 
Time Limit:  1 sec 
Source Limit:  50000 Bytes 
Languages:  ADA, ASM, BASH, BF, C, C99 strict, CAML, CLOJ, CLPS, CPP 4.3.2, CPP 4.9.2, CPP14, CS2, D, ERL, FORT, FS, GO, HASK, ICK, ICON, JAVA, JS, LISP clisp, LISP sbcl, LUA, NEM, NICE, NODEJS, PAS fpc, PAS gpc, PERL, PERL6, PHP, PIKE, PRLG, PYTH, PYTH 3.4, RUBY, SCALA, SCM guile, SCM qobi, ST, TCL, TEXT, WSPC 
Comments
 Please login at the top to post a comment.
SUCCESSFUL SUBMISSIONS
Fetching successful submissions
HELP
If you are still having problems, see a sample solution here. 
plz xplain any one
suppose A=1 and B=8 than in
A=1,2,3,4,5,6,7,B=8 find
how does 28 138 become 495?
@anyone can anyone explain
1537369 can yu pls email the
@admin what is wrong
I have no idea why i'm
why error (compile )time is
took me 3 hours to understand
How to overcome time limit
getting correct answers for
how to overcome the time
plz plz tell how to overcome
anyone explain the purpose of
Such an overcomplicated
my code runs correctly in the