摘要:
每次计算时间的消耗都需要依靠上一次的值,再加上本次的时间消耗。这是动态规划的特性。递推式为:v[i],表示电梯到第i次停靠时的时间消耗值。a[i],表示第i次电梯的停靠楼层。v[i] = v[i-1] + abs(a[i] -a[i-1])*6+5 当电梯向上升v[i] = v[i-1] + abs(a[i] -a[i-1])*4+5 当电梯向下降示例代码: 1 #include <iostream> 2 using namespace std; 3 int v[100]; 4 int add(int *a,int size) 5 { 6 memset(v,0,sizeof(v)) 阅读全文
posted @ 2012-04-13 18:58
笔记吧... 可能只有自己看得懂
阅读(870)
评论(0)
推荐(0)
摘要:
大致的思想:把数用字符串数组保存,然后转换到int型数组,最后完成加法。#include <iostream>using namespace std;void add(const char *str1,const char *str2){ int len1 = strlen(str1); int len2 = strlen(str2); int result[1000]; int a1[1000]; int a2[1000]; memset(result,0,sizeof(result)); memset(a1,0,sizeof(a1)); me... 阅读全文
posted @ 2012-04-13 18:29
笔记吧... 可能只有自己看得懂
阅读(226)
评论(0)
推荐(0)
摘要:
http://acm.nuaa.edu.cn/acmhome/problemdetail.do?&method=showdetail&id=1138分析:这是一个求解发生概率的问题。为了问题描述的方面,假设x表示猴子到来的时间为x,猴子摘香蕉的时间为a,小女孩到来的时间为y,小女孩采蘑菇的时间为b。能够得到以下式子:可以看出这是一个线性规划的问题,得到如下图示:也就是求如上图中,阴影部分在60*60的面积中所占的比率值。示例代码如下: 1 #include <iostream> 2 #include <iomanip> 3 using namespace 阅读全文
posted @ 2012-04-13 13:37
笔记吧... 可能只有自己看得懂
阅读(228)
评论(0)
推荐(0)
浙公网安备 33010602011771号