上一页 1 ··· 142 143 144 145 146 147 148 149 150 ··· 182 下一页
摘要: krustra最小生成树View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <algorithm>using namespace std;#define maxm 10005#define maxn 2005struct Edge{ int a, b, l;}edge[maxm];int father[maxn];int n, m;bool operator < (const Edge &a, 阅读全文
posted @ 2011-05-27 10:46 undefined2024 阅读(401) 评论(0) 推荐(0)
摘要: 题意:有n周,第i周:需要向外供货yi,生产1单位成本ci。若非本周生产的货物不在本周销售,需要贮藏,1单位贮藏一周需要花费s。问n周供货供需花费多少钱(成本和贮藏费)。分析:贪心,我们用mini记录当前的最小单价,然后以最小单价买入,这个最小单价,要么是现在的单价,要么是之前的最小单价+贮藏费。mini中被替换掉的值是不可能是以后的最小单价的。因为现在被替换,同时+上若干个s之后它还是会比现在替换它的那个值大。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include & 阅读全文
posted @ 2011-05-26 18:28 undefined2024 阅读(508) 评论(0) 推荐(0)
摘要: 多重背包,多重背包可以转化为完全背包和01背包。如果某东西的总体积大于包体积,则可以当成是完全背包。否则按物品体积的1,2,4...倍分别进行01背包。这样就相当于构成了所有的可能情况,例如5 = 4 + 1, 7 = 1 + 2 + 4。都可以由这些数字构成。View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <algorithm>using namespace std;#define maxn 405# 阅读全文
posted @ 2011-05-26 18:04 undefined2024 阅读(491) 评论(0) 推荐(0)
摘要: 简单题View Code #include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>using namespace std;int main(){ int r, m, y; //freopen("t.txt", "r", stdin); scanf("%d%d%d", &r, &m, &y); long double ans = m; 阅读全文
posted @ 2011-05-25 12:50 undefined2024 阅读(189) 评论(0) 推荐(0)
摘要: 高精度,java做View Code import java.util.*;import java.io.*;import java.math.*;public class Main { static public void main(String args[]) throws FileNotFoundException{ Scanner cin = new Scanner(new BufferedInputStream(System.in)); //Scanner cin = new Scanner(new FileInputStream("t.txt")); Strin 阅读全文
posted @ 2011-05-25 12:36 undefined2024 阅读(194) 评论(0) 推荐(0)
上一页 1 ··· 142 143 144 145 146 147 148 149 150 ··· 182 下一页