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 1289. One Way Ticket

those who want hint
Posted by manishmmulani 4 Jan 2008 01:44
for N,

####...N/2times ####...N/2 times
consider first half N/2 digits

sum(digit root) will always be from 0 to 9
it will be 0 only if all digits are 0's
and it'll will 1,2,3 .... ,9 in other cases...

for N=4
first half will have 2 digits ( total 100 numbers )
1 number(00) will have digit root = 0
99 numbers will have digit root other than 0
( i.e 11 numberes --> digit root 1 , 11 numbers ---> digit root 2 etc )

so for N=4 ,
case i : first half = 00 second half =00 -----> n1 = 1
case ii: first half --> 99 ways , second half --> 11 ways  n2= 99*11

total number = n1+n2 = 99*11 + 1

similarly for N=6 , we have 999*111 + 1
N=8 , 9999*1111 + 1
so on...
Hint
Posted by ASK 17 Mar 2010 15:17
Do not use BigInteger to calculate. Let k = n/2, then the result is 10 for k=1; otherwise it is a concatenation of "1"x(k-1), "0", "8"x(k-2), and "90":

1 10
2 1090
3 110890
4 11108890
5 1111088890
6 111110888890
7 11111108888890
8 1111111088888890
9 111111110888888890