自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Tornado

纸上得来终觉浅,绝知此事要躬行!

  • 博客(55)
  • 资源 (1)
  • 收藏
  • 关注

原创 poj 1936 all in all

#include #include using namespace std;bool issubsequence(string str1,string str2){ int length1=str1.length(),length2=str2.length(); int j=0,i=0; for(;i<length1;i++,j++){ while(j<length2 && s

2013-07-21 20:25:29 558

原创 N个数中第k大的元素

// 3 implement the function : int part(int *a,int low,int high), and implement the function to find the k-st num in a array a[low] as the pivot element int part(int *a,int low,int high){ int temp

2013-06-30 20:16:50 596

原创 poj 2593 max sequence

/*busyfisher 2013/6/25poj 2593 max sequence动态规划:分别求出从左到右顺序数组的最大子数组和从右到左顺序数组的最大子数组; ans = max{dp_left[i]+dp_left[i+1] | 1<=i<N}Memory: 1432K Time: 204MSLanguage: C++ Result: Accepted*

2013-06-25 21:11:45 579

转载 北邮ACM推荐50题

北邮ACM推荐50题POJ推荐50题1、标记“难”和“稍难”的题目可以看看,思考一下,不做要求,当然有能力的同学可以直接切掉。2、标记为A and B的题目是比较相似的题目,建议大家两个一起做,可以对比总结,且二者算作一个题目。3、列表中大约有70个题目。大家选做其中的50道,且每类题目有最低数量限制。4、这里不少题目在BUPT ACM FTP上面都有代码,

2013-06-25 19:29:31 821

原创 save

#include using namespace std;bool is_magic(int n){ bool is_four = false; int count = 0; while(n/10){ int t = n%10; if(t == 1){ is_four = false; count = 0; } else if(t == 4){ is

2013-06-23 22:21:31 556

原创 poj 1330 nearest common ancestor

/*busyfisher 2013/6/23poj 1330 nearest common ancestor用数组分别记录节点到根节点的路径,找出两个数组中,第一个相同的元素Memory: 364K Time: 141MSLanguage: C++ Result: Accepted*/#include #include using namespace std;

2013-06-23 19:46:25 500

原创 poj 1007 DNA sorting

/*DNA sortingTAGS: STL MAPMemory: 276K Time: 32MSLanguage: C++ Result: Accepted*/#include #include #include #include using namespace std;#define maxn 110string data[maxn];multima

2013-06-23 17:47:29 497

原创 poj 2013 Symmetric Order

#include #include using namespace std;string data[20];int main(){ int n; int count = 1; while(cin>> n && n){ for(int i =1;i<=n;i++){ cin>>data[i]; } int index[20]; //

2013-06-20 20:03:53 486

原创 poj 1979 red and black

#include #include #define maxn 21char map[maxn][maxn];int result[maxn][maxn];int w,h;int main(){ while(scanf("%d %d",&w,&h) && w && h){ memset(result,0,sizeof(result)); for(int i = 0;i

2013-06-20 19:38:55 602

原创 poj 1207 3n+1

#include int count(int x){ int value = 0; if(x == 1) return 1; else { while(x != 1) { if(x%2 == 0) x /=2; else x = 3*x + 1; value++; } } return value+1;}int main()

2013-06-20 18:55:30 495

原创 poj 3176 cow bowling

/*//// main.cpp// cow bowling//// Created by busyfisher on 13-6-20.// Copyright (c) 2013年 busyfisher. All rights reserved.// 位置图: 0 0 1 0 1 2 0 1 2

2013-06-20 16:18:02 502

原创 poj 1159 palindrome

/*busyfisher 2013/6/20动态规划dp[i][j] 表示以str[i]开始以str[j]结束的子字符串称为回文需要加入的最少字符数递推式如下:Memory: 40756K Time: 1485MSLanguage: C++ Result: Accepted*/#include #include using namespace std;

2013-06-20 09:59:13 502

原创 poj 1836 Aligment

/*busyfisher 2013/6/19poj 1836 Alignment动态规划,最长递增子序列分别前后计算最长递增子序列,注意考虑前后有相同身高的情况测试数据:3 4 5 1 2 5 4 323 4 5 4 30*/#include using namespace std;#define maxn 1000+10float data[m

2013-06-19 23:07:18 611

原创 poj find the multiple

题目大意:给定一个数,求该数的一个倍数,该倍数满足十进制表示时只包括0和1.使用宽度优先搜索,使用的暴力搜索,使用queue会超时,自己实现一个简易队列就行。#include using namespace std;long long bfs(int x){ long long store[1000000]; int start = 0,rear = 1; store

2013-06-19 20:05:12 581

原创 boost库之noncopyable类

1. 当声明一个类时,编译器会自动为该类生成默认构造函数,复制构造函数,赋值操作符以及析构函数;2.自动生成的各个函数和操作符都是public的;3.当声明一个类不允许复制时,可以将一个类的复制构造函数和赋值操作符声明为private,但是实际中,一般写一个noncopyable类,让不允许使用复制构造函数的类继承于该noncopyable类,boost类就实现了那么一个基类,代码很简单如

2013-06-17 23:01:33 879

原创 湖南师范大学第四届大学生计算机程序设计竞赛练习

蛇形矩阵Time Limit: 1000ms, Special Time Limit:2500ms, Memory Limit:32768KBTotal submit users: 44, Accepted users: 44Problem 11315 : No special judgementProblem description

2013-06-17 11:26:20 1088

原创 湖南师范大学第四届大学生计算机程序设计竞赛练习

缺失的数字Time Limit: 1000ms, Special Time Limit:2500ms, Memory Limit:65536KBTotal submit users: 50, Accepted users: 49Problem 11314 : No special judgementProblem description

2013-06-17 11:25:17 958

原创 湖南师范大学第四届大学生计算机程序设计竞赛练习

关系Time Limit: 3000ms, Special Time Limit:7500ms, Memory Limit:65536KBTotal submit users: 34, Accepted users: 29Problem 11312 : No special judgementProblem description  在多

2013-06-17 11:22:42 1181

原创 1840 poj Eqsa

对于数学表达式,ai,xi的范围[-50,50]且x不能为0,将表达式变型为时间复杂度O(10^6)#include using namespace std;int coe[5];short ans[40000000];int main(){ int result=0; for(int i=0;i<5;i++) cin>>coe[i]; for(int

2013-06-14 22:55:07 8912

原创 poj 2485 Highways

最小生成树的应用,之前用过prim算法实现,现在用kruskal算法实现,用并查集;开始的时候一直runtime error,是数组开的小的原因AC代码如下:#include #include #include #include using namespace std;#define maxn (500+500)typedef struct node{ in

2013-06-14 21:09:43 482

原创 mac下virtualbox安装ubuntu12.04出现问题

The system is running in low-graphic modeYour screen, graphics card and input devices settings could not be detected correctly. You will configure these yourself.同时按住control + alt + F1 进入命

2013-06-11 00:13:25 866

原创 poj 1328 Radar Installation

#include #include #include #include using namespace std;#define maxn 1000+10typedef struct pos{ double left; double right;}pos; //记录每个岛屿的圆心左边界和右边界pos position[maxn];

2013-06-09 14:37:41 453

原创 poj 2001 shortest prefix

前缀树的简单应用,我的思路是每次加入单词是,为每个节点记录一个value,该value代表经过该节点的单词数目,每次取最短前缀时,只需要沿着单词查找第一个value值为1的节点,即表示只有该单词经过该节点。C++写的代码,有点啰嗦..0MS AC#include #include using namespace std;#define max_words 1100

2013-06-07 20:46:05 550

原创 poj 1321 棋盘问题

深度优先搜索代码:#include #include using namespace std;int n,k;char array[10][10]; //to record the chessboardbool visited[10]; //to record each line's statusint ans ;int sum ;void dfs

2013-06-06 22:53:28 498

原创 crack the code interview chapter 1

#crack the code interview handwrite code#chapter 1 arrays and strings#1.1 implement an algorithm to determine if a string has all unique characters,#requirement:no additional data structures// C

2013-06-04 21:13:20 791

原创 python , 一个简单的单线程的C/S模型示例

代码来自Foundations of python network programmingpython 版本2.7launcelot.py# !/usr/bin/env pythonimport socket,sysPORT = 1060qa = (('What is your name?','My name is Sir Lanucelot of Camelo

2013-05-31 14:33:25 684

原创 python 网络编程 小知识积累

python版本 3.31 python获得每个端口对应的协议# !/usr/bin/env pythonimport socketfor j in range(40000): try: temp = socket.getservbyport(j) except OSError: continue string = str

2013-05-31 00:15:48 603

原创 poj 2533 Longest Order Sequence

基础的最长递增子序列,递推式代码如下,时间复杂度O(n*n)#include using namespace std;#define maxn 1000+10int data[maxn];int dp[maxn];int main(){ int num; cin>>num; for(int i=1;i<=num;i++) cin>>data[i]; d

2013-05-30 10:18:12 413

原创 python 实现的简单的BloomFilter

一个简单的BloomFilter的python实现,接触python没多久,代码不是很规范# /usr/bin/env python#python implemented simple bloomfilterclass BloomFilter(): def __init__(self,length): self.length = length

2013-05-29 11:03:53 1964

原创 poj 1258 Agri-Nets

#include #include using namespace std;#define maxn 100+10#define max 100000int graph[maxn][maxn];bool visited[maxn];int dis[maxn];int nodes;int prime(int start){ memset(visited,false,s

2013-05-28 20:16:46 485

原创 poj 1797 Heavy Transportation

#include #include #include #include using namespace std;#define maxn 1000+10int nodes,edges;int weight[maxn][maxn];bool visited[maxn];int dis[maxn];int dij(int start){ for(int i=1;i<=nod

2013-05-28 11:00:39 484

原创 POJ Argus

该题的归类是归并排序,我用的是STL中的MAP,算是MAP的运用吧;题目衔接:http://poj.org/problem?id=2051题目大意:有若干查询,每一个查询都有查询号和间隔时间,求从开始时刻的前K个查询的编号,我的做法是先将所有的查询都放在map中,每次取第一个pair,以及键值和第一个pai相同的pair,即同一时刻发生的所有查询,并将该查询的下一次查询时间加入map中,最

2013-05-24 12:24:33 610

原创 动态规划 poj 2479 1458

两个基本题,求和最大的子数组和最长公共子串,应该熟练掌握这两种类型的动态规划最优解代码如下: Common Subsequence#include #include #include #include #include using namespace std;#define max_length 1000int result[max_length][max_lengt

2013-05-22 20:31:28 490

原创 poj 2253 frogger

题目衔接:http://poj.org/problem?id=2253题解:求出图中两点所有路径中权值最大数中的最小值,即可简化为求最小生成树中的距离最大值AC代码:Memory: 584K Time: 16MSLanguage: C++ Result: Accepted#include #include #include #include #include

2013-05-20 22:21:44 450

原创 poj 3126 Prime path

题目衔接:http://poj.org/problem?id=3126题目大意:对一个4位数进行变换,每次只能变一个数字,求变化到另一数字的最小变换数,注意第一位不能为0,用宽度优先搜索,第一次找到该数字时,即为最小变换次数代码如下:#include #include #include using namespace std;#define maxn 10

2013-05-17 16:46:56 462

原创 BFS poj Catch that cow

题目衔接:http://poj.org/problem?id=3278代码:#include #include #include using namespace std;#define maxn 200000+10int data[maxn];bool visited[maxn];queue store;int bfs(int N,int K){ while(!sto

2013-05-09 19:46:00 450

原创 poj 2503 babelfish

题目比较简单,但是输入比较纠结,我是用getline函数获取一行,再处理的,可以判断字符是否为空格来分开,我直接用sstream处理了,有点小题大做,用时比较多;使用map比较方便Memory: 9620K Time: 1813MSLanguage: C++ Result: Accepted#include #include #include #include #inc

2013-05-06 22:51:19 463

原创 不相交集合 poj 1703 find them catch them

题目衔接:http://poj.org/problem?id=1703题目大意:一个囚犯可能属于A牢,可能属于B牢,给出每个不属于同一囚牢的条件,判断两个囚犯是否属于一个囚牢;思路:使用并查集数据结构,由于只有两个囚牢,与同一个囚犯不是一个囚牢的囚犯必然属于同一个囚牢,相同囚牢的囚犯归并带一个集合,同时记录与囚犯处于不同囚牢的囚犯集合,还是看代码吧.#include #include

2013-05-06 16:30:44 543

原创 vs2012 Boost库的使用

下载boost库:http://www.boost.org/开始在使用时总是显示错误:无法打开”libboost_date_time-vc110-mt-gd-1_53“boost库的安装:最新版的boost库的安装比较方便,打开boostrap批处理文件,在执行生成的bjam(全部安装),也可部分安装,可参考其他博客。vs2012的配置:项目属性->VC++目录

2013-05-02 11:01:26 1022

原创 C++类中的静态成员

静态成员一、           静态数据成员独立于该类的所有对象,是与类直接关联的,由该类的所有对象共同拥有,相当于类作用域中的全局变量,在类作用域能直接访问。二、           This指针是用于指向类的对象的,而静态成员不是与类关联的,所以静态成员不同通过this形参调用,静态成员函数不能访问非静态数据成员,而非静态成员函数既能访问静态成员也能访问非静态数据成员;三、

2013-04-30 21:03:25 733

开放流网络实验调研

关于开放流网络实验的调研,对于开放流网络的理解有一定帮助

2013-06-26

空空如也

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

TA关注的人

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