GeekVan

导航

2017年1月18日 #

01背包问题(动态规划求解)

摘要: 01背包的状态转换方程 f[i,j] = Max{ f[i-1,j-Wi]+Pi( j >= Wi ), f[i-1,j] } Wi为第i件物品的重量,Pi为第i件物品的价值。 测试数据:重量4,价值6;重量5,价值4;重量6,价值5;重量2,价值3;重量2,价值6;背包总重量限制为10 代码: 测 阅读全文

posted @ 2017-01-18 08:45 GeekVan 阅读(278) 评论(0) 推荐(0) 编辑

2017年1月1日 #

数塔问题(DP算法)自底向上计算最大值

摘要: Input 输入数据首先包括一个整数C,表示测试实例的个数,每个测试实例的第一行是一个整数N(1 <= N <= 100),表示数塔的高度,接下来用N行数字表示数塔,其中第i行有个i个整数,且所有的整数均在区间[0,99]内。 Output 对于每个测试实例,输出可能得到的最大和,每个实例的输出占一 阅读全文

posted @ 2017-01-01 00:55 GeekVan 阅读(2897) 评论(0) 推荐(0) 编辑

2016年12月31日 #

拦截导弹问题

摘要: 拦截导弹动态规划问题 某国为了防御敌国的导弹袭击,发展出一种导弹拦截系统。但是这种导弹拦截系统有一个缺陷:虽然它的第一发炮弹能够到达任意的高度,但是以后每一发炮弹都不能高于前一发的高度。某天,雷达捕捉到敌国的导弹来袭。由于该系统还在试用阶段,所以只有一套系统,因此有可能不能拦截所有的导弹。 输入导弹 阅读全文

posted @ 2016-12-31 16:57 GeekVan 阅读(537) 评论(0) 推荐(0) 编辑

PALIN - The Next Palindrome 对称的数

摘要: A positive integer is called a palindrome if its representation in the decimal system is the same when read from left to right and from right to left. 阅读全文

posted @ 2016-12-31 14:24 GeekVan 阅读(240) 评论(0) 推荐(0) 编辑

Prime Generator

摘要: Peter wants to generate some prime numbers for his cryptosystem. Help him! Your task is to generate all prime numbers between two given numbers! Input 阅读全文

posted @ 2016-12-31 13:16 GeekVan 阅读(278) 评论(0) 推荐(0) 编辑