ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1044. Lucky Tickets. Easy!

A combinatorial approach
Posted by abid1729 25 Jun 2019 00:31
firstly, if 1st 2 digits and 2nd 2 digits are same then there will be 10*10=100 combinations of 2 digits.
for every number there will be 2 combination.(example:1212 and 1221)
so,combinations will be 2*100=200. But there are such 10 numbers for which 2 combinations are not available.(ex: 0000 , 1111 , 5555)
COMBINATIONS = 200-10 = 190.
now, we have to check from highest 9+9=18 to lowest 0+0=0 that how much sets have same sum.
     16<<<< (9+7),(8+8)
     15<<<< (9+6),(8+7)
     14<<<< (9+5),(8+6),(7+7)
     13<<<< (9+4),(8+5),(7+6)
     12<<<< (9+3),(8+4),(7+5),(6+6)
     11<<<< (9+2),(8+3),(7+4),(6+5)
     10<<<< (9+1),(8+2),(7+3),(6+4),(5+5)
      9<<<< (9+0),(8+1),(7+2),(6+3),(5+4)
      8<<<< (8+0),(7+1),(6+2),(5+3),(4+4)
      7<<<< (7+0),(6+1),(5+2),(4+3)
      6<<<< (6+0),(5+1),(4+2),(3+3)
      5<<<< (5+0),(4+1),(3+2)
      4<<<< (4+0),(3+1),(2+2)
      3<<<< (3+0),(2+1)
      2<<<< (2+0),(1+1)

  combinations =(2*2*2/2)+(2*2*2)+(2*2*2+2*2+2*2) +(3*2*2*2)+..................................+(2*2*2)+(2*2) =480

SO, total combinations = 190+480 =670