×

 0 Question can anyone explain this code Code Please explain how he uses MOD operation. asked 03 Oct '12, 14:32 336●4●10●19 accept rate: 3%

 0 The solution uses dynamic programming approach. In this problem , you can keep (number of digits , current weight , previous digit used) as a state and find the number of ways accordingly .State Transition is simple as : you can try each digit from 0 to 9 , and check if its weight is within limits,then add it to the answer. The MOD operation is simple. Since the answer can be really big, instead of storing the final answer and taking the modulus , you can take the modulus at each step , thus keeping the number within the range. You may find Modular Arithmetic useful. answered 03 Oct '12, 17:03 627●1●7●13 accept rate: 27%
 toggle preview community wiki:
Preview

By Email:

Markdown Basics

• *italic* or _italic_
• **bold** or __bold__
• image?![alt text](/path/img.jpg "title")
• numbered list: 1. Foo 2. Bar
• to add a line break simply add two spaces to where you would like the new line to be.
• basic HTML tags are also supported
• mathemetical formulas in Latex between \$ symbol

Question tags:

×3,820
×3

question asked: 03 Oct '12, 14:32

question was seen: 2,092 times

last updated: 03 Oct '12, 17:03