X.er86

导航

2012年12月4日 #

POJ_2479与POJ_2593 Maximum Sum

摘要: 题目链接:POJ 2479:http://poj.org/problem?id=2479POJ 2593:http://poj.org/problem?id=2593分类:动态规划算法:两道题目除了输入格式不同以外,其它算法一样,利用双向动态规划算法。(1)最原始的计算方法设有数组长度为,用一个的矩阵进行和的存储,即则计算的时间复杂度为:接下来,需要求出不相交的两段和的最大值。设为数组的分界,则第一段是,第二段是,的取值范围为,因此计算最大值的过程中,需要比较的次数为:因此计算步骤为因此渐进时间复杂度为。(2)利用单向动态规划算法如果原题中是求一段连续子序列的和,即因此可以利用动态规划算法(最 阅读全文

posted @ 2012-12-04 12:17 X.er86 阅读(163) 评论(0) 推荐(0)

2012年12月1日 #

POJ_1003~1005 普通简单题

摘要: 1003:Hangover原题链接:http://poj.org/problem?id=1003 1 #include<iostream> 2 #include<cstdio> 3 4 using namespace std; 5 6 int main() 7 { 8 double c; 9 while (cin >> c && c != 0)10 {11 double total = 0; // 计算突出的长度12 int n;13 for (n = 1; ; n++)14 ... 阅读全文

posted @ 2012-12-01 18:25 X.er86 阅读(46) 评论(0) 推荐(0)

POJ_1002:487-3279

摘要: 原题链接:http://poj.org/problem?id=1002分类:字符串处理与哈希映射算法:将字符串先转换为整数,将整数作为数组下标进行出现次数的统计,count数组开始初始化为0,统计整数的出现次数。c++源代码: 1 #include<iostream> 2 #include<string> 3 #include<cmath> 4 5 using namespace std; 6 7 long n; 8 long count[10000000] = {0}; 9 10 long change_s(string);11 string change 阅读全文

posted @ 2012-12-01 16:25 X.er86 阅读(136) 评论(0) 推荐(0)

2012年11月30日 #

POJ_1001:Exponentiation

摘要: 原题链接:http://poj.org/problem?id=1001分类:高精度计算算法:按照小学生手算的方法进行计算,利用字符串对数字进行处理。c++源代码: 1 #include<iostream> 2 #include<string> 3 #include<vector> 4 5 using namespace std; 6 7 string times_func(string s1, string s2); // 用于计算两个大数的乘法(高精度乘法) 8 string solve(string s, int n); // 用于计... 阅读全文

posted @ 2012-11-30 14:29 X.er86 阅读(172) 评论(0) 推荐(0)