Can anyone help me about this question. I found those numbers that elif wins between 0 and 100: 11, 22, 33, 44, 55, 66, 77, 88, 99, 101, 110, 123, 132, 145, 154, 167, 176, 189, 198. However, I couldn't figure out the general pattern among them.
The Number Game
KEO and Elif love card games. They decided to play one turn as part of their ritual, however they are bored playing the ordinary games, so they invented their own. Their game is played by the following rules:
• Before starting the game, a number N is determined.
• KEO goes first in every game and they take turns consecutively.
• Assume that both players play the game optimally.
• In their turns, players replace a non-zero digit of the number N with a smaller digit. (i.e. 5024 -> 1024, the player chose 5 and replaced it with 1.)
• The purpose of the game is to obtain 0 from the chosen number N in their turns.
You are asked to find how many times KEO and Elif will win the game in the range [L, R] (including L&R).
Input Format The first line contains the number of test cases (T). The next T lines contain numbers L and R consecutively.
Output Format Print wins of KEO and Elif consecutively for every test case in the given range.
Sample Input 2 1 11 100 200
Sample Output 10 1 91 10
Explanation For the first test case, for numbers {1,2,3,4,5,6,7,8,9,10} KEO may replace any of them with 0 in the first turn and wins the game. For the number {11}, KEO is obliged to replace it with {10} or {01}. Next, Elif may replace 10 or 1 with 0 and wins the game. Eventually, in the given range, KEO wins for 10 numbers, Elif wins for 1 number.
Aucun commentaire:
Enregistrer un commentaire