Last active
March 23, 2019 13:33
-
-
Save wintercn/5596588 to your computer and use it in GitHub Desktop.
现在有1分、2分、5分的硬币各无限枚,要凑成1元有多少种凑法?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function getResult(n,coins) { | |
| var a = new Array(n+1); | |
| for(var i = 0; i <= n;i++) | |
| a[i] = 0; | |
| a[0] = 1; | |
| for(var j = 0; j<coins.length; j++) | |
| for(var i = 0; i <= n;i++) | |
| a[i+coins[j]] += a[i]; | |
| return a[n]; | |
| } | |
| getResult(100,[1,2,5]); // 541 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
我厂前端同学的解法(haskell):
详见http://zhanglin.pro/19