上一页 1 ··· 26 27 28 29 30 31 32 33 34 ··· 182 下一页
摘要: 排序二叉树View Code #include <iostream>#include <cstdlib>#include <cstdio>#include <cstring>using namespace std;#define maxn 105struct Node{ Node *left, *right; char letter;}tree[maxn];char st[maxn];int node_cnt;void insert(Node * &proot, char ch){ if (proot == NULL) { proot = 阅读全文
posted @ 2013-03-26 15:46 undefined2024 阅读(462) 评论(0) 推荐(0)
摘要: dfs+排序View Code //zoj1684//注意字典序排序,是按照逐个单词比较出来的,每个句子的第x个单词只和其他句子的第x个单词进行比较。先比第一个单词再比第二个单词//例如: 句子"i am"的字典序就在句子"ia m"的前面//还有根据g++编译器,string是不能进行memset的,否则会出错。#include <iostream>#include <string>using namespace std;const int maxn = 105, maxl = 105, maxa = 105;struct wo 阅读全文
posted @ 2013-03-26 15:19 undefined2024 阅读(244) 评论(0) 推荐(0)
摘要: dpView Code #include <iostream>#include <cstdlib>#include <cstdio>#include <cstring>using namespace std;#define maxn 105#define inf 0x3f3f3f3fint n;int f[maxn];int g[maxn][maxn];int main(){ //freopen("t.txt", "r", stdin); scanf("%d", &n); for 阅读全文
posted @ 2013-03-26 14:24 undefined2024 阅读(348) 评论(0) 推荐(0)
摘要: dp注意要多dp出一段,因为有时候付钱需要超过100元再找钱。求和函数accumulate需要包含头文件numeric,使用方法为sum = accumulate(f, f + n, 0);求最大值函数max_element返回最大值指针,需要包含头文件algorithm,使用方法为max_value=*max_element(f, f+n);View Code #include <iostream>#include <cstdio>#include <cstring>#include <cstdlib>#include <algorith 阅读全文
posted @ 2013-03-26 13:49 undefined2024 阅读(218) 评论(0) 推荐(0)
摘要: 题意:有若干种货币,某些币种之间可兑换,给出各种兑换时的汇率和手续费,任何兑换都是双向的,但是两个方向的汇率和手续费可能不同,并告知你现在拥有的货币种类(只拥有一种)及数量,问是否可以通过货币建兑换最后回到本币种后钱数有所增加。分析:普通的货币兑换一般都是用floyd。但是本题除了汇率还多出一个条件——手续费,所以不能简单地使用floyd。我用的是spfa求最长路,检查是否有环路。从自己的币种出发,如果发现正环,那么则可以不停地走环路以增加自己手中的价值,又因为所有的路都是双向的,所以当手中的价值增加的足够多之后是一定可以回到自己原有的币种的。又因为正环能使价值达到正无穷,所以回去之后价值一定 阅读全文
posted @ 2013-03-21 20:54 undefined2024 阅读(1959) 评论(0) 推荐(1)
上一页 1 ··· 26 27 28 29 30 31 32 33 34 ··· 182 下一页