uva 10313 - Pay the Price
来源:互联网 发布:tomcat的默认端口 编辑:程序博客网 时间:2024/05/18 02:29
import java.io.*;import java.math.BigInteger;import java.util.*;public class Main{ public static void main (String [] args) throws Exception { Scanner scan = new Scanner(System.in); long dp[][] = new long[301][301]; for(int i=0;i<301;i++){ dp[0][i] = 1; } for(int i=1;i<301;i++){ for(int j=1;j<301;j++){ dp[i][j] = (i>=j?dp[i-j][j]:0)+dp[i][j-1]; } } while(scan.hasNextLine()){ String s = scan.nextLine(); s = s.trim(); if(s.length()==0) return; String arr[] = s.split(" "); int n = Integer.parseInt(arr[0]); int start = 0; int end = 0; if(arr.length==1){ end = n; } if(arr.length==2){ end = Integer.parseInt(arr[1]); } if(arr.length==3){ start = Integer.parseInt(arr[1]); end = Integer.parseInt(arr[2]); } if(end>n) end = n; if(start-1<0) start = 1; if(n==0) System.out.println(1); else System.out.println(dp[n][end]-dp[n][start-1]); } }}
这题怎么说呢,貌似TM有个定理,用J个或者少于J个数组成一个大数的方法和用最大为J的数组成大数方法总数一样。
然后JB这题变成了完全背包。。。还可以用滚动数组优化
其实不知道定理也可以拿个N立方的dp公式来推,就是K再循环一次,悲剧的是我N立方的公式退错了。。。
- uva 10313 Pay the Price
- UVA 10313 Pay the Price
- UVA 10313 Pay the Price
- uva 10313 - Pay the Price
- UVA - 10313 Pay the Price
- UVa:10313 Pay the Price
- uva 10313 - Pay the Price
- UVa 10313 - Pay the Price
- UVA - 10313 Pay the Price
- UVA - 10313 Pay the Price
- uva 10313 Pay the Price
- UVA 10313-Pay the Price(DP)
- uva 10313 Pay the Price (DP)
- Pay the Price+uva+dp
- 10313 - Pay the Price
- 10313 - Pay the Price
- 解题报告(一):uva 10313 - Pay the Price (dp)
- uva 10313 Pay the Price(完全背包)
- 11 款最好 CSS 框架 让你的网站独领风骚
- CSS关于子元素设置了float属性后父元素高度为0的解释和解决方法
-
- 程序员面试—5大算法
- cocos2d-x 设置资源路径需要注意问题
- uva 10313 - Pay the Price
- Windows编程之管道技术
- timus 1073 Square Country
- 几种开放源码的TCPIP协议栈概述--LwIP,uIP,TinyTcp和uC/IP
- “#if 0/#if 1 ... #endif”的注释作用
- linux SysV IPC shm共享内存实现
- Oracle内存全面分析之PGA
- Design Pattern_Builder(建造者模式)
- 解决mysql“Access denied for user 'root'@'localhost'”