自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 文本查询程序

重写TextQuery和QueryResult类,用StrBlob代替vector保存输入文件:我为StrBlobPtr重载了一个deref成员函数:string& StrBlobPtr::deref(int num) const{ std::shared_ptr> p = check(curr + num, "dereference past end!"); return (*p)[c

2016-07-06 22:20:06 358

原创 给定一个字符串表达式s,计算其值(使用string和stack实现)

toPosfix函数将中缀表达式转换为后缀表达式,calculatePosfix函数计算后缀表达式的值。#include #include #include using std::string;using std::stack;using std::cout;using std::cin;using std::endl;string &toPosfix(string &

2016-06-22 21:13:49 1323

原创 telnet smtp 发送邮件

注意账号密码都要用base64加密的,(base64可能会加密错误,这时候建议换一个密码) telnet smtp.163.com 25helo glxauth loginZ2c5NzE4OTYyNjZAMTYzLmNvbQ==********//加密后的密码mail from:rcpt to://想要发送的邮箱地址datasubject:ceshifrom:to:

2016-05-17 14:43:39 1105

转载 POJ 3525 二分答案,推进多边形和半平面交

转载:http://blog.csdn.net/non_cease/article/details/7814970题目在问这样一个问题:给定一个凸多边形,找到其中的一个点,使得其到每条边的距离最小值最大,输出这个距离。其实就是在问你,这个多边形中最大的一个内切圆有多大。怎么做呢?如果我们事先知道一个半径R,我们是不是能验证这个R是否可行呢?答案是肯定的,这样想:如果我们把这个多边形

2016-05-17 13:10:41 551

原创 《python程序设计》第二章基本程序设计笔记

直接赋值,不需声明数据类型,例如:radius=20,即相当于int radius=20;s=input("en")print(eval("1+2+3"))radius=sradius=9.1radius=radius*2print(radius)var1,var2=1,2print(var1,var2)a,b,c=eval(input("jfsd"))print(a,b

2016-05-16 19:27:57 479

原创 《python语言程序设计》第一章python概述 笔记

#为行注释,三个单引号'''为段注释python输入语句是从新行的第一列开始的,区分大小写import turtle #载入turtleturtle.showturtle()turtle.write("Welcome to Python" )#在此绘制一个文本字符串turtle.forward(100)#向此时方向前进一百个像素turtle.right(90)#向右拐90turt

2016-05-16 19:25:13 1533

原创 《深入理解计算机系统》第一章计算机系统漫游笔记

在计算机中,数据是以一串位(bit)序列的形式储存,其中八个位组成一个字节。对于只由ASCII字符构成的文件称为文本文件,其余所有文件均称为二进制文件。这一组组位依据上下文有不同的解释。程序经过预处理器(将头文件插入程序文本中)->编译器(为不同的高级语言提供相同输出语言)->汇编器(将汇编程序翻译成机器语言(二进制))后被翻译成二进制文件,通过链接器(调用程序中使用的函数)翻译成可执行目标文

2016-05-16 19:22:18 428

原创 计算机网络(原书第六版) 第二章笔记

2.1.1 网络应用程序体系结构网络体系结构是固定的,应用程序体系结构是应用程序研发者设计的。网络应用程序两种主流结构:客户-服务体系结构;对等(p2p)体系结构。在p2p体系结构中,应用程序在间断连接的主机对之间使用直接通信,这些主机被称为对等方。2.1.2 进程通信是进程进行通信,而不是程序进行通信。对每对通信进程,我们通

2016-05-16 19:16:29 763

原创 poj 3335(半平面交)

计算几何中半平面交的一个重要用法既是确定多边形的核。 平面简单多边形的核是该多边形内部的一个点集,该点集中任意一点与多边形边界上一点的连线都处于这个多边形内部。就是一个在一个房子里面放一个摄像 头,能将所有的地方监视到的放摄像头的地点的集合即为多边形的核。原多边形称为vera,切割后的多变形称为verb。 顺序给出一个多边形各个顶点的点集, 首先另verb=vera。 我们从第一个点开始,选

2016-05-15 20:05:24 436

原创 poj 1654(计算几何)(差乘运用)

任意多边形的面积可由任意一点与多边形上依次两点连线构成的三角形矢量面积求和得出。 证明: http://www.cnblogs.com/vbspine/archive/2013/03/28/2987818.html#include<iostream>#include<algorithm>#include<cstdio>#include<cstring>#include<string>#

2016-05-13 20:32:34 353

原创 poj 2318(计算几何)

TOYS Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 13238 Accepted: 6396Description Calculate the number of toys that land in each bin of a partitioned toy box. Mom and dad

2016-05-13 17:57:41 362

原创 poj 2398 (计算几何)

#include <iostream> #include <stdio.h> #include <string.h> #include <algorithm> using namespace std; struct Point { long long int x, y; }; struct

2016-05-11 21:21:06 331

原创 加分二叉树(感觉像是区间dp)

【问题描述】 设一个n个节点的二叉树tree的中序遍历为(l,2,3,…,n),其中数字1,2,3,…,n为节点编号。 每个节点都有一个分数(均为正整数),记第i个节点的分数为di,tree及它的每个子树都 有一个加分,任一棵子树subtree(也包含tree本身)的加分计算方法如下: subtree的左子树的加分× subtree的右子树的加分+subtree的根的分数

2016-05-10 17:09:40 732

原创 CSU 1725 加尔鲁什·地狱咆哮对阵虚灵大盗拉法姆

E - 加尔鲁什·地狱咆哮对阵虚灵大盗拉法姆                            Time Limit:1000MS    Memory Limit:131072KB    64bit IO Format:%lld & %llu                                                                  S

2016-05-04 16:03:52 604

原创 ZOJ Problem Set - 3640

Help Me EscapeTime Limit: 2 Seconds     Memory Limit: 32768 KB     If thou doest well, shalt thou not be accepted? and if thou doest not well, sin lieth at the door. And unto thee sh

2016-05-03 17:12:37 265

原创 Codeforces 148D D Bag of mice(概率dp1)

D. Bag of micetime limit per test2 secondsmemory limit per test256 megabytesinputstandard inputoutputstandard outputThe dragon and the princess are arguing about what t

2016-05-03 15:12:35 264

原创 ZOJ Problem Set - 3946 Highway Project

Highway ProjectTime Limit: 2 Seconds      Memory Limit: 65536 KB Edward, the emperor of the Marjar Empire, wants to build some bidirectional highways so that he can reach other cities from t

2016-04-27 13:26:13 275

原创 华工校赛 F. Bracket Sequence

F. Bracket SequenceTime Limit: 1 Sec, Memory Limit: 128 MBDescriptionA bracket sequence is a string,containing only characters "(", ")", "[" and"]". A correct bracket sequence is a bracket seque

2016-04-27 10:30:53 457

原创 GCJ1C09C - Bribe the Prisoners

GCJ1C09C - Bribe the Prisonersno tags  ProblemIn a kingdom there are prison cells (numbered 1 to P) built to form a straight line segment. Cells number i and i+1 ar

2016-04-20 20:54:38 414

原创 hdu 1058 Humble Numbers

B - Humble NumbersTime Limit:1000MS     Memory Limit:32768KB     64bit IO Format:%I64d & %I64uSubmit Status Practice HDU 1058DescriptionA number whose only prime factors are 2,3,5

2016-04-13 20:19:46 231

原创 hdu 1025

JGShining's kingdom consists of 2n(n is no more than 500,000) small cities which are located in two parallel lines.Half of these cities are rich in resource (we call them rich cities) while the

2016-04-13 17:10:39 236

原创 扩展欧几里得算法

扩展欧几里得能快速解a*x+b*y=gcd(a,b)。#include<iostream>#include<cstdio>#include<algorithm>using namespace std;int extgcd(int a,int b,int &x,int &y){ int d=a; if(b!=0) { d=extgcd(b,a%b,y,

2016-03-23 21:59:48 238

原创 uva 10891

题目链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1832 题目思路: 题目的目的是使A得更多分。设某序列为序列a,A取最优f(a),使其变成序列b,B取最优,一直取到序列为0. 那么怎么取呢,取的这一步必定包含在从左端取一个到全部或者从右

2016-02-02 16:59:19 278

原创 LA 3902 网络

原是不会的,看了蓝皮书的分析,后自己实现了这个想法。#include<iostream>#include<cstdio>#include<vector>#include<algorithm>using namespace std;const int N=1005;vector<int> depth[N],node[N];int t;int n,s,k;int parent[N];

2015-12-23 22:29:43 582

转载 uva 11464

题目链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2459 枚举第一行的状态,可以得出任意一行的状态。#include<iostream>#include<cstdio>#include<algorithm>#include<cstrin

2015-12-02 21:15:15 393

原创 codeforces 492B

英语不好,比赛时没看懂题。 题意:两个人a,b。a只能从点f(1,1)出发前往f(n,m),只能向右或向下走,b从f(n,1)出发前往f(1,m),只能向上或向右走。且他们走过的轨迹只能有一个交点。 分析:1.因为只能有一个交点,所以对于某一点f(i,j)来说,只存在两种情况,一种是 - (1)a从f(i-1,j)进入f(i,j)走向f(i+1,j), - (2)b从f(i,j-1)进入

2015-11-24 20:43:55 417

原创 poj 3345 Bribing FIPA

比赛的时候做的这题,坑爹的,我这近段时间一直学树形dp,结果这唯一一道树形dp的题目我居然没看懂!! 这道题dp部分比较容易想出来,难点是输入格式,一直runtime error。 dp[v][j]:在结点v与它的子孙结点中选出j个城市需要付出的最小代价。dp[v][j]=min(dp[v][j],dp[son][k]+dp[v][j-k]);//son为v的一个子结点n和m的输入建议用ssca

2015-11-23 23:08:09 966

原创 poj 2184 Cow Exhibition(01背包)

题目链接:http://poj.org/problem?id=2184 a[i]:第i头牛smartness,b[i]:第i头牛funness. 因为题目中存在负数,第一点先消除负数的状态,看题目可知可定义shift=100000为0点。 dp[i][j]:前i头牛总smartness为j的情况下,总的smartness和funness最大的大小。 dp[i][j]=max(dp[i-1][

2015-11-19 21:49:52 227

原创 hdoj 2546 饭卡

题目连接:http://acm.hdu.edu.cn/showproblem.php?pid=2546 遇到这一类有限定条件的dp,先想想有什么方法能将它转化为普通dp,然后在用丰富的经验ac它 只要m>5,则最贵的菜必选。升序排序,01背包计算出前n-1道菜最多花费。#include<iostream>#include<cstdio>#include<cstring>#include<a

2015-11-19 15:44:15 370

原创 福州大学有奖月赛2015.11C题(foj 2207)以撒的结合

题目链接:http://acm.fzu.edu.cn/problem.php?pid=2207 比赛时这题感觉不会,赛后看了一下,其实并不是什么特别难的题目。以节点1为根节点,找出每一个节点的父亲节点,保存在数组parent[]中。对于任意两个节点,循环找出两个节点最近的根节点。(Find函数部分)#include<iostream>#include<cstdio>#include<al

2015-11-18 20:23:52 554

原创 poj 1155 TELE (树形dp)

题目链接:http://poj.org/problem?id=1155 参考了这位acmer的,我用的是vector的方法:http://blog.csdn.net/woshi250hua/article/details/7635680 dp[i][j]:以结点i为根节点时拥有j个客户的最大价值。当结点i为叶子结点时,dp[i][1]=money[i];当结点i非叶子结点,dp[i][j]=

2015-11-15 01:10:05 264

原创 zoj 1395 可行遍性问题

题目连接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=1395 对于无向图的可行遍性问题。无向图G是仅有两个奇结点的连通图,且G的欧拉通路以此两个端点为端点。G是无奇结点的连通图是,必有欧拉回路。 这道题的难点在于数据处理。 我是这样处理的int readline(char s[]){ int i=

2015-11-13 17:12:05 392

原创 SPFA

未验证,我记录一下#include<iostream>#include<cstdio>#include<algorithm>#include<queue>using namespace std;struct node{ int to; int weight; node* next;};queue<int> q;const int N=105;const i

2015-11-11 20:39:33 237

原创 zoj 2975 Kinds of Fuwas

题目连接: http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemCode=2975 不知道怎么回事,这种题总是不会。 枚举行数,判断有无两行有无相同字母。#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>using namespace s

2015-11-11 14:39:42 284

原创 zoj 2972 Hurdles of 110m

体力值最高为m,刚开始没看到,一直wa。 dp[i][j]:跑完前i个区域还剩j点体力值。 所以有四种情况: 用a[i][5]数组储存每一行输入的五个数。 - if(j+a[i][3]<=m) dp[i][j]=min(dp[i][j],dp[i-1][j+a[i][3]); - dp[i][j]=min(dp[i][j],dp[i-1][j]); - if(j-a[i][4]>=

2015-11-11 13:48:37 268

原创 判定最小生成树是否唯一

1,对图中每条边,扫描其他边,若存在相同权值的边,标记。 2.用kruskal算法或prim算法构造mst。 3.求得mst后,若mst不含有标记的边,则mst唯一。若有,则依次去掉标记过的边,再求mst,若求得的mst权值与原mst权值相等,即可判定该mst不唯一。 poj 1679(简单题): http://poj.org/problem?id=1679模板题:#include<iost

2015-11-05 21:16:20 1001 1

原创 prim算法(普里姆算法)

Prim算法: http://blog.chinaunix.net/uid-25324849-id-2182922.html#include<iostream>#include<cstdio>#include<algorithm>#include<cstring>using namespace std;const int N=105;const int INF=1<<29;int n

2015-11-05 11:19:16 410

原创 CSU 1537 Miscalculation

模拟题,c[i]储存原串,用一个栈装数字,遇到乘号将栈顶元素取出与乘号后一个数字相乘,将乘积放入栈中。#include<iostream>#include<cstdio>#include<stack>#include<cstring>#include<string>using namespace std;const int N=105;int main(){ char c[N

2015-11-03 14:03:54 423

原创 中缀表达式转后缀表达式

自己写的烂代码,可能bug百出,并且只能计算10以内的数。先记录一下#include<iostream>#include<cstdio>#include<stack>#include<string>using namespace std;stack<char> ss;int main(){ char s[100]; char s1[100]; memset(s1

2015-11-02 21:30:07 257

原创 CSU 1536 bit string reordering

首先构造出两个满足条件的字符串储存在s1,s2,原串储存在s。 比较s1串s2串中‘1’的个数是否和s串中的‘1’的个数相等。若相等,则统计转换的次数。 统计转换次数的方法看compare函数。#include<iostream>#include<cstdio>#include<cmath>#include<algorithm>using namespace std;char s1[2

2015-11-02 20:31:06 425

空空如也

空空如也

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

TA关注的人

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