书山有径勤为路>>>>>>>>

<<<<<<<<学海无涯苦作舟!

2011年10月12日

大整数乘法——简单

摘要: 写这个程序的时候有三个关键点,知道了这个,你Win, Or, 你Lose!我将它们一一注释在了代码中。View Code #include "iostream"#include "cstring"#include "string"using namespace std;#define maxlen 200int a[maxlen]; int b[maxlen]; int c[2*maxlen+1]; //这个地方也是个关键,一定要多加一个正数,不然错string s1;string s2;int main(){ while(cin&g 阅读全文

posted @ 2011-10-12 11:24 More study needed. 阅读(311) 评论(0) 推荐(0) 编辑

2011年10月10日

大整数加法——带有负数的

摘要: #include "iostream"#include "string"#include "cstring"using namespace std;#define maxlen 2001int a[maxlen];int b[maxlen];int len1, len2, i, j;int bigger(int a, int b){ return a>b?a:b;}void Add(int underzero){ if(underzero) cout<<'-'; int big = bigger(le 阅读全文

posted @ 2011-10-10 21:53 More study needed. 阅读(491) 评论(0) 推荐(0) 编辑

大整数加法——最简单的

摘要: #include<iostream>#include<string>#include<cstring>using namespace std;#define maxlen 200int a[maxlen];int b[maxlen];int bigger(int a, int b){ return a>b?a:b;}int main(){ string s1, s2; while(cin>>s1>>s2) { int len1 = s1.length(); int len2 = s2.length(); memset(a, 0, 阅读全文

posted @ 2011-10-10 21:51 More study needed. 阅读(199) 评论(0) 推荐(0) 编辑

2011年10月7日

spfa算法解决POJ 2387

摘要: DescriptionBessie is out in the field and wants to get back to the barn to get as much sleep as possible before Farmer John wakes her for the morning milking. Bessie needs her beauty sleep, so she wants to get back as quickly as possible.Farmer John's field has N (2 <= N <= 1000) landmarks 阅读全文

posted @ 2011-10-07 10:20 More study needed. 阅读(229) 评论(0) 推荐(0) 编辑

2011年10月4日

BellmanFord解决POJ 3259

摘要: 题目:http://poj.org/problem?id=3259题目大意:一个famer有一些农场,这些农场里面有一些田地,田地里面有一些虫洞,田地和田地之间有路,虫洞有这样的性质: 时间倒流。问你这个农民能不能看到他自己,也就是说,有没有这样一条路径,能利用虫洞的时间倒流的性质,让这个人能在这个点出发前回去,这样他就是能看到他自己了 其实要想搞明白这道题目十分的简单,但前提是,你看了我的“Dijkstra算法解决POJ 2263”这篇文章,其余的也就不多说了,该说的我都在注释中说明白了。View Code #include<iostream>using namespace st 阅读全文

posted @ 2011-10-04 20:27 More study needed. 阅读(461) 评论(0) 推荐(0) 编辑

Floyd算法解决POJ 2263

摘要: DescriptionBig Johnsson Trucks Inc. is a company specialized in manufacturing big trucks. Their latest model, the Godzilla V12, is so big that the amount of cargo you can transport with it is never limited by the truck itself. It is only limited by the weight restrictions that apply for the roads al 阅读全文

posted @ 2011-10-04 11:52 More study needed. 阅读(380) 评论(0) 推荐(0) 编辑

2011年10月3日

Dijkstra解决POJ 2263

摘要: 题目:http://poj.org/problem?id=2263题目大意:有n个城市,r条连接两个城市的道路,每条道路有自己的最大复载量。现在问从城市cst到城市cen,车上的最大载重能为多少。虽然是提交了,也搞懂了,但是还没有彻底的明白。因此,也不便多说什么,当我彻底明白的时候再说吧。呵呵,终于完全的明白了,下面指出一二。1.一定要明白map[][]的双关性,何为双关? (1).map[i][j]表示i到j的距离 (2).map[i][j]=0表示i到j不可以直接可达 要达到这种效果,首先将map[][]全部赋值为0, 然后存储建图,在建图的过程中自然的将直接可达 的两点赋值为不... 阅读全文

posted @ 2011-10-03 22:21 More study needed. 阅读(1201) 评论(2) 推荐(2) 编辑

Floyd算法解决POJ 1603

摘要: DescriptionRisk is a board game in which several opposing players attempt to conquer the world. The gameboard consists of a world map broken up into hypothetical countries. During a player's turn, armies stationed in one country are only allowed to attack only countries with which they share a c 阅读全文

posted @ 2011-10-03 19:42 More study needed. 阅读(539) 评论(0) 推荐(0) 编辑

2011年10月2日

sscanf 你会用吗?

摘要: DescriptionYou have just moved from Waterloo to a big city. The people here speak an incomprehensible dialect of a foreign language. Fortunately, you have a dictionary to help you understand them.InputInput consists of up to 100,000 dictionary entries, followed by a blank line, followed by a message 阅读全文

posted @ 2011-10-02 17:21 More study needed. 阅读(240) 评论(0) 推荐(0) 编辑

Trie解决POJ 2503

摘要: 题目:http://poj.org/problem?id=2503就是一个字典树的简单应用, 不解释。View Code #include "iostream"using namespace std;typedef struct node{ char word[21]; int mark; struct node * next[26];}node;node * root;void InitRoot(){ root = new node(); root->mark=0; memset(root->next, NULL, sizeof(root->next)) 阅读全文

posted @ 2011-10-02 17:10 More study needed. 阅读(275) 评论(0) 推荐(0) 编辑

导航

书山有径勤为路>>>>>>>>

<<<<<<<<学海无涯苦作舟!