Problem Description Your friend is preparing for maths olympiad. He is trying to solve sample papers. He finds it difficult to solve a specific type of question, so he always approaches you for help....


Problem Description






Your friend is preparing for maths olympiad. He is trying to solve sample papers. He finds it difficult to solve a specific type of question, so he always approaches you for help. As you are busy in your own preparation, you decided to provide him with a code that will help him calculate the correct answer for the given question.






In the question, you are given with a 'number'. You have to pick exactly 4 digits from the number, and form a new 4 digit number (the order of the digits is






retained). This 4 digit number is said to be stable, if the number satisfies following conditions: 1. First 2 digits of the number formed are same, say x 2. Last 2 digits of the number formed are same, say y. 3. x and y satisfy the following relation: x + 1 = y. Your task is to tell number of ways of selecting 4 digits from the number such that the 4 digit number formed is stable. As the answer may be large, output the answer modulus 1049+7


Consider the example with number="101222".There are 3 ways of forming a stable 4 digit number, We can form "1122" by picking digits at index 0, 2, 3, 4.






We can form "1122" by picking digits at index 0, 2, 3,






5. We can form "1122" by picking digits at index 0, 2, 4, 5.






Therefore, the answer is






INPUT:






First and only line contains a string 'number'.






OUTPUT FORMAT:






Output the number of ways of selecting 4 digit stable number






CONSTRAINTS






1


's'






0






SAMPLE INPUT:






22233424






SAMPLE OUTPUT:






4






SAMPLE EXPLANATION:






number="22233424






There are 4 ways of forming a stable 4 digit number. We can form "2233" by picking digits at index 0,1.3. 4 We can form "2233" by picking digits at index 1, 2, 3,






4






We can form 2233" by picking digits at index 0.2.3.


22233424






SAMPLE OUTPUT:






4






SAMPLE EXPLANATION:






number="22233424"






There are 4 ways of forming a stable 4 digit number We can form 2233" by picking digits at index 0, 1, 3, 4






We can form "2233" by picking digits at index 1, 2, 3,






4






We can form 2233" by picking digits at index 0, 2, 3, 4 We can form 3344" by picking digits at index 3, 4, 5,7






Therefore, the answer is 4.



Aug 01, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here