摘要:
标准的贪心,先将供应商按照价格的升序排序,然后按需购买价格低的牛奶就可以得到最小的总价。/*ID:yucept21LANG:C++TASK:milk*/#include<cstdio>#include<cstdlib>#include<cstring>typedef struct tt{ int price, amount;}T;int N, M;T milk[5005];int cmp( const void *_p, const void *_q){ T *p = (T *)_p; T *q = (T *)_q; return p->price - 阅读全文
posted @ 2012-02-02 16:26
找回失去的
阅读(196)
评论(0)
推荐(0)
摘要:
真心不知道怎么用动归,然后网上找到的做法:I think this problem's tip is.. len=string length Mutant : len is 1, and str[0]='B' Simple : if len is 1, and str[0]='A' Fully-Grown : str[len-1]='B', and str[len-2]='A' Mutagenic : str[0]='B', and str[len-1]='A' Else : Mutant然 阅读全文
posted @ 2012-02-02 15:45
找回失去的
阅读(209)
评论(0)
推荐(0)
摘要:
求出一个矩阵的最大和,我们可以按照行和列计算一块区域的和然后和ans比较,更新ans的值。最后得出的就是所求的最大值。#include<cstdio>#include<cstring>#include<cstdlib>#define MAXN 110int n, ans;int mat[MAXN][MAXN];int max( int a, int b){ return a > b ? a : b;}int dp( int k){ int f[MAXN], a[MAXN]; memset( f, 0, sizeof f); memset( a, 0, 阅读全文
posted @ 2012-02-02 14:55
找回失去的
阅读(379)
评论(0)
推荐(1)
浙公网安备 33010602011771号