COCI 2007/2008, Contest #3
Task CUDAK
Božo is a strange little boy. Every day he tires his friends with strange questions. Today's question is: how many integers in the interval [A, B] are there such that the sum of their digits is S, and which is the smallest such number?
Write a program that answers Božo's question so that he can get some sleep.
Input
The input contains three integers A, B and S (1 ≤ A ≤ B < 1015, 1 ≤ S ≤ 135).
Output
The first line should contain the number of integers in the interval with the digit sum equal to S.
The second line should contain the smallest such integer.
The input data will guarantee that the first number is at least 1.
Scoring
For correctly outputting one of the two numbers you will receive 50% of the score.
Note: if you want to receive credit for just the second number, be sure to output something (0, for example) as the first number so the judge can interpret your output correctly.
Examples
Input1 9 5 Output1 5 |
Input1 100 10 Output9 19 |
Input11111 99999 24 Output5445 11499 |
All Submissions
Best Solutions
Point Value: 15 (partial)
Time Limit: 1.00s
Memory Limit: 32M
Added: Aug 13, 2013
Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3
Comments (Search)
It's quiet in here...