自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(14)
  • 收藏
  • 关注

原创 POJ2253《Frogger》方法:Floyd-Wallshall

将Floyd算法中求每对顶点间的最小距离,条件换成每对顶点间最长序列的最大跳数,所以要多加进去k。#include #include #include #include using namespace std;class coordinate {public: double x, y;} points[201];double path[201][201];int m

2013-02-28 10:36:15 683

原创 POJ1062《昂贵的聘礼》方法:dijkstra

娶酋长媳妇需要10000,但是在拥有物品2时就需要8000,有物品3时需要5000,并且交易时不能和超过等级差的人先后交易,所以每一次先以当前等级为最大等级并且不超过等级差,dis[1]为目标点,运用dijkstra求单源最短路径,每一次的源点是从最小的dis[i]开始。#include #include #include #include using namespace std;

2013-02-27 21:55:29 316

原创 POJ3259《Wormholes》方法:Bellman-ford

农夫要回到原点,找一条负权环,注意输入有正权双向路径和负权单向路径。#include #include #include using namespace std;int all = 0; //有向边数int dis[501]; //源点到各点权值int N, M, W; // N点数,M正权双向边数,W负权单向边数class weight{public: int s

2013-02-27 10:57:55 305

原创 POJ1860《Currency Exchange》方法:反向Bellman-ford

就是求一条正权回环,方法在于反向使用bellman-ford。#include #include #include using namespace std;int n; //货币种数int m; //交换点int s; //目前持有的货币种类double v; //持有货币钱数int all=0; //边数double dis[101]; //源点到各点的权值cla

2013-02-26 12:38:28 340

原创 POJ3982《序列》方法:高精度

水题,变种斐波那契数列大数相加,注意全0的情况。#include #include #include #define size 100using namespace std;void add(char *a, char *b, char *c, char *d) { int ta[size] = {0}; int tb[size] = {0}; int tc[size]

2013-02-25 20:21:19 366

原创 POJ2602《Superlong sums》方法:高精度 模拟

题目比较拗口的大数相加,两个数居然分开一个数字一个数字读入,注意要用scanf()读入,cin因为重载,没有指定格式,输入比较耗时。同时输出也要先转换为字符串形式,不然循环输出整数数组会超时。#include #include #include using namespace std;int n; // 输入长度int main(){ //freopen("temp.txt

2013-02-25 10:15:31 401

原创 POJ2389《Bull Math》方法:高精度 模拟

大数相乘,注意给单步结果最高位留一个位置,如#include #include #include using namespace std;int main(){ //freopen("temp.txt", "r", stdin); char ca[41], cb[41]; cin >> ca >> cb; int a[40], b[41], c[80]; memset(

2013-02-24 11:03:31 355

原创 POJ1503《Integer Inquiry》方法:模拟 高精度

简单的大数相加哈#include #include #include using namespace std;int main(){ //freopen("temp.txt", "r", stdin); int c[102], ans[102]; char s[101]; // s[100]可能是'\0' memset(ans, 0, sizeof(ans)); wh

2013-02-23 12:25:30 372

原创 POJ1001《Exponentiation》方法:模拟 高精度

就是求浮点数乘方运算的幂#include #include #include using namespace std;#define SIZE 1000int main(){ // freopen("temp.txt", "r", stdin); char s[20]; int ans[SIZE]; int n; while (cin >> s >> n) {

2013-02-22 17:05:10 257

原创 POJ3087《Shuffle'm Up》方法:模拟

模拟洗牌,使用map,判断是否会形成死循环。#include #include #include #include #include using namespace std;int main(){ freopen("temp.txt", "r", stdin); int t = 0, test; cin >> test; while (++t <= test) {

2013-02-21 10:11:13 403

原创 POJ2993《Emag eht htiw Em Pleh》方法:模拟

就是将POJ2996进行反向输出#include #include #include using namespace std;class whit {public: int row; char col; char type;} ww[16];class blac {public: int row; char col; char type;} bb[16];

2013-02-20 16:20:18 325

原创 POJ2996《Help Me with the Game》方法:模拟

国际象棋棋盘换一种方式输出,模拟无难度。#include #include #include using namespace std;class white_piece {public: int row; char col; bool flag; // 就给K,Q用呗} K, Q, R[3], B[3], N[3]; // 3是为了做交换临时空间用bool

2013-02-20 11:32:03 310

原创 POJ1573《Robot Motion》方法:模拟

纯粹的模拟,无难度#include #include #include using namespace std;int main(){ int row, col, entry; char grid[12][12]; //freopen("temp.txt", "r", stdin); while (true) { memset(grid, 'O', sizeof(gr

2013-02-19 16:25:43 397

原创 POJ2774《Long Long Message》方法:后缀数组

就是求两个字符串的最长公共字符串,使用后缀数组,空间复杂度O(nlogn),花了2天时间来搞懂后缀数组,但是测试了很多数据没有发现什么错误,不知为什么这题在G++是RE,在C++下是WA,先贴代码,日后再分析。注意两个字符串之间要加分隔符#include #include #include using namespace std;#define maxasc 128#define

2013-02-01 22:51:06 372

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除