Money System
来源:互联网 发布:电信网络经常闪断 编辑:程序博客网 时间:2024/05/16 00:38
/*ID: daniel.20LANG: JAVATASK: money */import java.io.*;import java.util.*;public class money { static int target, num; static int[] arr; static long[] table; public static void initial() throws Exception { BufferedReader reader = new BufferedReader(new FileReader("money.in")); StringTokenizer st = new StringTokenizer(reader.readLine()); num = Integer.parseInt(st.nextToken()); target = Integer.parseInt(st.nextToken()); arr = new int[num]; int count = 0; while (count < num) { if (st.hasMoreTokens()) { arr[count++] = Integer.parseInt(st.nextToken()); } else { st = new StringTokenizer(reader.readLine()); } } table = new long[10001]; table[0] = 1; } public static void dp() throws Exception { PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("money.out"))); for (int i = 0; i < num; ++i) { for (int j = arr[i]; j <= target; ++j) { table[j] += table[j - arr[i]]; } } out.println(table[target]); out.close(); } public static void main(String[] args) throws Exception { initial(); dp(); System.exit(0); }}
完全背包,写的比较顺利,30分钟就搞定了,输入数据没看清有多行,wa一次
感觉代码算比较简洁了. 继续!
- Money System
- money system
- USACO:Money System
- usaco Money system
- Money
- Money
- money
- money
- Money
- money
- money
- Money
- Money
- Money
- USACO Money System 背包9讲,动态规划,母函数
- USACO解题思路分析记录(Money System)
- 构造 ACdream1408 "Money, Money, Money"
- hdu 1408 acdearm "Money, Money, Money"
- Windows平台ssh登录linux并使用图形化界面
- JFreeChart API
- 看IT大战
- iframe滚动条的样式
- Network Manager碰到的问题
- Money System
- 异常中的finally和方法中的return
- 惹恼程序员的十件事
- JVM参数对J2EE性能优化的影响
- C/C++ 在控制台下显示进度
- internal(C# 参考)
- 每天学习一算法系列(34)(求一个二叉树中任意两个节点间的最大距离,两个节点的距离的定义是这两个节点间边的个数)
- [Linux]svn服务的安装和启动设置
- 使用Memory Analyzer tool(MAT)分析内存泄漏(二)