日本搞逼视频_黄色一级片免费在线观看_色99久久_性明星video另类hd_欧美77_综合在线视频

國內最全IT社區平臺 聯系我們 | 收藏本站
阿里云優惠2
您當前位置:首頁 > php開源 > php教程 > poj3181 Dollar Dayz (DP+大數)

poj3181 Dollar Dayz (DP+大數)

來源:程序員人生   發布時間:2016-06-01 17:18:11 閱讀次數:2442次

Dollar Dayz
Crawling in process... Crawling failed Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u
Submit Status Practice POJ 3181
Appoint description:

Description

Farmer John goes to Dollar Days at The Cow Store and discovers an unlimited number of tools on sale. During his first visit, the tools are selling variously for $1, $2, and $3. Farmer John has exactly $5 to spend. He can buy 5 tools at $1 each or 1 tool at $3 and an additional 1 tool at $2. Of course, there are other combinations for a total of 5 different ways FJ can spend all his money on tools. Here they are:

        1 @ US$3 + 1 @ US$2 
 1 @ US$3 + 2 @ US$1 
 1 @ US$2 + 3 @ US$1 
 2 @ US$2 + 1 @ US$1 
 5 @ US$1
Write a program than will compute the number of ways FJ can spend N dollars (1 <= N <= 1000) at The Cow Store for tools on sale with a cost of $1..$K (1 <= K <= 100).

Input

A single line with two space-separated integers: N and K.

Output

A single line with a single integer that is the number of unique ways FJ can spend his money.

Sample Input

5 3

Sample Output

5
1個DP題 不過由于數太大了。。。所以我選用的java...

其中dp數組存貯組成當前數的個數

import java.math.*; import java.util.*; public class Main { public static void main(String[] args) { Scanner sca =new Scanner(System.in); int k,n; while(sca.hasNext()) { n=sca.nextInt(); k=sca.nextInt(); BigInteger dp []=new BigInteger[1005]; for(int i=0;i<1005;i++) dp[i]=BigInteger.ZERO; dp[0]=BigInteger.ONE; for(int i=1;i<=k;i++){ for(int j=0;j<=n;j++){ if(j>=i&&dp[j-i]!=BigInteger.ZERO){ dp[j]=dp[j].add(dp[j-i]); } } } System.out.println(dp[n]); } } }



生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 俺去俺来也在线www色官网 | 中文字幕三区 | 99久精品视频 | 久久久久国产一区二区三区 | 看全黄大色黄大片老人做 | 成人免费视频在线观看 | 久久一区二区视频 | 国产精品一区不卡 | 99免费视频| 日韩一页 | 精品999久久久| 中文字幕av一区二区三区 | 黄色网址av | 欧美成人日韩 | www.夜夜骑.com | 韩日中文字幕 | 99在线视频观看 | 在线观看黄色毛片 | 日产精品久久久久久久 | 欧美福利一区 | 久久鬼 | 日本大胆欧美 | 高清视频一区二区 | 成人av电影网站 | 国产成人在线网站 | 久久最新网址 | 国内精品国产三级国产在线专 | 国产成人精品综合 | 日日日操操操 | 成人欧美一区二区三区视频xxx | 一区二区不卡视频 | a级片在线免费观看视频 | 成人av网站在线观看 | 玖玖在线视频 | 欧美在线播放一区 | www.国产精| 在线国产区 | 久久久国产一区二区三区 | 国产一区久久 | 免费a v在线| 少妇精品久久久一区二区三区 |