Sherlock and Dates
Practice
3.4 (18 votes)
Ad Hoc
Algorithms
Approved
Easy
Open
Problem
25% Success 6253 Attempts 20 Points 1s Time Limit 256MB Memory 1024 KB Max Code

Watson was observing in calendar dates of form DD:MM:YYYY. He considers a date to be lucky if

  1. DD + 1 = MM and
  2. MM + 1 = YYYY % 100, where a % b denotes the remainder when a is divided by b.

For example, date 02:03:2004 is lucky because 02 + 1 = 03 and 03 + 1 = 2004 % 100.

Now comes Sherlock and Watson gives him two dates, say D1 and D2, and asks him how many lucky dates lie between D1 and D2(both inclusive).

Input
First line contains T, the number of test cases. Each test case consists of two valid dates D1 and D2(in form DD:MM:YYYY) separated by a space. D2 occurs on or after D1.

Output
For each test case, print the required answer in one line.

Constraints
1 ≤ T ≤ 104
1 ≤ Year of each date ≤ 9999
20% testdata: Years D1 and D2 don't differ by more than 10
20% testdata: Years D1 and D2 don't differ by more than 100
60% testdata: General constraints.

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:20
111 votes
Tags:
Ad-HocApprovedEasyOpenString Manipulation
Points:20
30 votes
Tags:
Ad-HocBasic ProgrammingEasy
Points:20
22 votes
Tags:
Ad-HocApprovedEasyImplementationMathOpen