Thursday, 20 November 2014

CODEFORCES ROUND # 277.5 Div2 C. Given Length and Sum of Digits...

Problem Link: http://codeforces.com/problemset/problem/489/C

Death Call Problem!!! :P

If number has length of m and having sum as S
then minimum amd maximum nos. could be found out by ::

Set MAXNO[m]= 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...................
Set MINNO[m]=1 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0...........

Increment the nos. in MAXNO from left till 9 and jump to its right till we get the required sum S
 Similarly ,
Increment the nos. in MINNO from right till 9 and jump to its left till we get the required sum S

These are our required results!!!!!!11

Dont miss the testcase: 1 0
Expected Output: 0 0

Code Link:  http://pastebin.com/eujy24nt

No comments:

Post a Comment