多多色-多人伦交性欧美在线观看-多人伦精品一区二区三区视频-多色视频-免费黄色视屏网站-免费黄色在线

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

poj3181 Dollar Dayz (DP+大數)

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

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]); } } }



生活不易,碼農辛苦
如果您覺得本網站對您的學習有所幫助,可以手機掃描二維碼進行捐贈
程序員人生
------分隔線----------------------------
分享到:
------分隔線----------------------------
關閉
程序員人生
主站蜘蛛池模板: 九色九色九色在线综合888 | 中文字幕欧美激情 | 久久精品成人 | 欧美人与性禽xxxx | 久久国产一区二区 | 伊人婷婷色 | 色网站综合 | 麻豆久久精品免费看国产 | 欧美 亚洲 中文字幕 | 欧美videosex性欧美成人 | 国产精品成人久久久 | 国产毛片片精品天天看视频 | 亚洲免费观看 | 成人免费看黄页网址大全 | 久久免费观看国产精品 | 欧美伦理一区 | 久久精品国产99久久99久久久 | 2019免费视频 | 亚洲国产最新在线一区二区 | 免费在线播放毛片 | 久久精品亚洲精品国产欧美 | 日韩欧美精品一区二区三区 | 91久久另类重口变态 | 99久久国产综合精品女不卡 | 国产丝袜一区二区三区在线观看 | 亚洲精品成人网久久久久久 | 欧美黑人性猛交 | 欧美高清video | 亚洲欧洲久久精品 | 欧美性xxx久久 | 欧美一区二区三区久久久 | 97午夜理伦影院在线观看 | 日本一级毛片在线观看 | 天堂最新版 | 天天做天天爱天天爽综合网 | 国产精品一区二区三区高清在线 | 精品视频在线播放 | 奇米影视88| 女女女女女女bbbbbb毛片 | 视频久久精品 | 日本一二三四区免费视频 |