自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 生死门问题

问题描述:公元某年某月某日,你迷失在一个山洞里,在你面前有两个门,一个生门,一个死门,分别有两个人守护这两个门,一个人永远说真话,一个人永远说假话,他们彼此知道对方是诚实人或撒谎人。请你问其中一个人一个问题,来判断哪个门是生门?哪个门是假门?答

2015-11-04 16:42:54 10515 1

原创 Python常见异常问题

2015-10-25 11:09:02 653

原创 python之len函数

>>> s1="今年是2015年。">>> s2="明年一定是2016年。">>> s3="后年就要毕业了。">>> len(s1)14>>> len(s2)18>>> len(s3)16>>> s4='''今年是2015年。明年一定是2016年。'''>>> len(s4)35>>> s5='''今年是2015年。明年一定是2016年。后年就要毕业了。'''

2015-10-20 09:25:25 2241

原创 随心一爬

#查询与该文件在同一目录下的所有文件import osw=os.getcwd()print wm=os.listdir(w)print m#查询ipimport socketbaiduip=socket.gethostbyname("www.baidu.com")print "百度的ip地址为:"print baiduip#爬虫网页import urllibimport

2015-10-17 22:05:50 1056

原创 Python之Split函数

#python中不存在单个字符的运算,只有字符串函数>>> s="www.google.com">>> s'www.google.com'>>> s.split('.') #无参数全部切割['www', 'google', 'com']>>> s.split('.',1) #分隔一次['www', 'google.com'

2015-10-17 16:39:56 12239

原创 Python基本数据结构 习题及源码

##习题1:#列表a = [11,22,24,29,30,32]#1 把28插入到列表的末端>>> a.append(28)>>> a[11, 22, 24, 29, 30, 32, 28]#2 在元素29后面插入元素57>>> a.insert(4,57)>>> a[11, 22, 24, 29, 57, 30, 32, 28]#3 把元素11修改成6>>> a[0

2015-10-16 22:46:19 3811

原创 Python学习之列表排序

对于python来说,尽可能用key来排序总是没错的。数字排序:>>> a[11, 22, 24, 21, 30, 12]>>> sorted(a)   #将a从小到大排序,不影响a本身结构[11, 12, 21, 22, 24, 30]>>> sorted(a,reverse=True) #将a从大到小排序,不影响a本身结构[30,

2015-10-16 20:09:20 1244

原创 PyCharm 4.5 外观设置教程

哈哈

2015-10-15 12:05:15 5619

转载 数据库之关系代数

转发自http://blog.csdn.net/auv1107/article/details/14648025     感谢原作者的整理关系代数是关系数据库系统查询语言的理论基础。很有必要学习一下,有些是用代数表达式很方便的东西,用SQL写出来还是挺麻烦的,并不是想象当中那么直接。 一、关系代数的9种操作:     关系代数中包括了:并

2015-10-15 11:45:48 1041

原创 原码一位乘和补码一位乘

今天学习了计算机中乘法的运算:原码一位乘和补码一位乘,在这做个笔记,顺便检验一下学习成果,有不足的地方希望大家不吝指教!1.原码一位乘首先注意,在乘法运算中,同号为正,异号为负。在这里我们用异或符号表达符号位:被乘数 [x]原 = xf .x0 x1 x2 … xn        乘数   [y]原 = yf .y0 y1 y2 … yn两者乘积   [ z ]原 =

2015-10-14 22:11:55 6564

原创 HDU 5074 Hatsune Miku DP

解题思路:题意为有m种音符,编号1到m,我们要用这m种音符来创造一首带有n个音符的曲子(当然,一种音符可以用多次),假设有两个连续的音符 i ,j ,那么定义score(i,j)为这两个音符的得分,题目中预先给出所有的score(i,j)   1<=i,j<=m, 那么我们创造出的n个音符的曲子的得分为  score( note[i] , note[i+1] ) + score (note

2015-08-06 09:39:25 450

原创 HDU 5119 Happy Matt Friends - DP

点击打开题目链接http://acm.hdu.edu.cn/showproblem.php?pid=5119#include#include#include#includeusing namespace std;int a[50];int dp[50][2000100];int cnt=1;int main(){ int T,n,m; sca

2015-08-03 10:32:13 539

原创 HDU 1796 容斥原理

点击打开题目链接http://acm.hdu.edu.cn/showproblem.php?pid=1796#include#include#include#includeusing namespace std;int arr[200];//int select[200];int n,m,cnt,ans;int gcd(int a,int b){ return

2015-08-03 09:48:42 420

原创 HDU 4786 Fibonacci Tree (2013ACMICPC 成都站 F) 并查集

点击打开题目链接http://acm.hdu.edu.cn/showproblem.php?pid=4786#include#includestruct Tree{ int a,b,c;}tree[110000];int node[110000];int fib[40];int n,m;void Fibonacci(){ int i; fib[0]=fib[1]

2015-08-03 09:43:46 622

转载 容斥原理

【组合数学_容斥原理专辑】总概述    专辑的开头贡献一篇容斥原理讲得非常好的文章,讲得十分清楚,很容易就明白容斥原理是什么。    http://www.cppblog.com/vici/archive/2011/09/05/155103.html。    我个人认为容斥原理就是用来解决基于集合的统计问题,不同题目的集合有很多不同的性质,我们利用容斥理解把只有一个性质的集

2015-07-31 17:09:13 833

转载 动态规划转移方程

Robberies http://acm.hdu.edu.cn/showproblem.php?pid=2955     背包;第一次做的时候把概率当做背包(放大100000倍化为整数):在此范围内最多能抢多少钱  最脑残的是把总的概率以为是抢N家银行的概率之和… 把状态转移方程写成了f[j]=max{f[j],f[j-q[i].v]+q[i].money}(f[j]表示在概率j之下能抢的大洋

2015-07-28 20:56:51 594

原创 2015 Multi-University Training Contest 1 /hdu 5289 Assignment -树状数组

点击打开题目链接http://acm.hdu.edu.cn/showproblem.php?pid=5289#include#include#includeusing namespace std;#define MAXN 100100#define lowbit(i) (i&(-i))int tree1[MAXN],tree2[MAXN];//int max(int a

2015-07-27 11:32:23 521

原创 poj 1011 Sticks - 经典DFS

点击打开题目链接//poj1011经典搜索#include#include#includeusing namespace std;int a[65];bool vis[65];int n;int dfs(int len,int need_len,int num)/*三个系数分别代表 当前的搜索长度, 达到目的要求还需要的长度, 还未拼接的木棒个数 */ {

2015-07-26 15:10:26 448

原创 poj 2151 Check the difficulty of problems- DP

点击打开题目链接http://poj.org/problem?id=2151RegisterUpdate your infoAuthors ranklistCurrent ContestPast ContestsScheduled ContestsAward Contestyangshengjie

2015-07-26 15:06:49 383

原创 poj3267 The Cow Lexicon -DP

点击打开题目链接http://poj.org/problem?id=3267The Cow LexiconTime Limit: 2000MS Memory Limit: 65536KTotal Submissions: 8722 Accepted: 4110DescriptionFew know th

2015-07-26 13:55:41 579

原创 poj 1837 Balance -DP

题目链接http://poj.org/problem?id=1837//思路:开一个G*(平衡度)的数组,DP找的就是状态,所以平衡度就是该状态~~表示DP真的不好~~继续DP吧!//dp[i][j] 表示在挂满前i个物体的时,平衡度为j的挂法的数量。j为正表示右面重。//最极端的情况是所有物体都挂在最远端,因此平衡度最大值为15*20*25=7500。原则上就应该有dp[ 0..20 ]

2015-07-24 17:53:01 463

原创 HDU 3635 Dragon balls -并查集

题目链接点击打开链接http://acm.hdu.edu.cn/showproblem.php?pid=3635#include#includeconst int MAXN=10010;int fath[MAXN],num[MAXN],move[MAXN];int N,Q ;void init(){ for(int i=1;i<=N;i++) { fath[i]=i

2015-07-24 14:53:14 449

原创 HDU 1242 Rescue BFS+优先队列

题目链接:点击打开链接http://acm.hdu.edu.cn/showproblem.php?pid=1242#include #include #include #include #include #include using namespace std;const int N=220;int n,m,stx,sty,endx,endy;char mp[N]

2015-07-23 20:01:20 636

原创 HDU 1431 素数回文-暴力枚举

题目链接:点击打开链接http://acm.hdu.edu.cn/showproblem.php?pid=1431这道题搞了几天一直Memory Limit Exceeded,始终找不到错误,求指教,不胜感激!后附有枚举代码!#include #include #include #include #include #include #include using

2015-07-23 19:58:41 730

原创 HDU 1271 整数对-组合数学

点击打开链接http://acm.hdu.edu.cn/showproblem.php?pid=1271#include#include#includeusing namespace std; int num[100];int main(){ int n; while(~scanf("%d",&n),n) { int a,b,c; int t=0;

2015-07-22 20:08:40 584

原创 HDU3388 -Coprime-容斥原理

友情题目链接http://acm.hdu.edu.cn/showproblem.php?pid=3388#include #include #include #include using namespace std;typedef long long LL;const int N=1000005;const LL INF=(LL)1<<62;bool prime[

2015-07-22 15:07:00 944 1

原创 HDU 2577 How to Type 动态规划

友情题目链接http://acm.hdu.edu.cn/showproblem.php?pid=2577#include#include#includeusing namespace std;const int N=110;char str[N];int close[N],open[N];int MIN(int a ,int b){ return a=a<b?a:b;}i

2015-07-22 09:22:40 680

原创 计算机网络习题辅导

第一章 测验 1.TCP/IP参考模型中的网络接口层(Network Access)对应了OSI参考模型中的( )。A.网络层 B.数据链路层和物理层 C.数据链路层 D.物理层答案关键: B2.下列Internet应用中,基于C/S计算模式的是()。A.FTP B.BT  C.MSN D.Skype答案关键: A3. 数据链路层传输的数据单位是 ( )A.bi

2015-07-21 21:40:52 6361

原创 计算机网络知识点

计算机网络学习目标:了解抽象虚拟的网络结构,更好的蹭WIFI(Wireless Fidelity 无线保真) 简述1983年 ARPANET 采用TCP/IP 协议族因特网标准是以RFC的形式发表因特网的正式标准经历四个阶段:1. 因特网草案2. 建议标准3. 草案标准4. 因特网标准因特网的组成:边缘部分(连接在因特网上的主机组成,用户直接使用

2015-07-21 21:38:11 840

原创 HDU 1251 统计难题-字典树

友情题目链接http://acm.hdu.edu.cn/showproblem.php?pid=1251基础字典树:#include#includechar s[15];struct node{ int cnt; node *next[26]; void init() //初始化 { cnt=0; for(int i=0;i<26;i++) {

2015-07-21 21:34:24 551

原创 hdoj 2277 Change the ball 【找规律】

友情题目链接http://acm.hdu.edu.cn/showproblem.php?pid=2277#include#includeusing namespace std;int main(){ int a[3]; while(~scanf("%d%d%d",&a[0],&a[1],&a[2])) { sort(a,a+3); if(a[0]==a[1]||(

2015-07-21 21:27:44 559

原创 poj 2594 Treasure Exploration 最小路径覆盖/最大匹配

题目链接:点击打开链接http://poj.org/problem?id=2594#include#includeconst int N=510;int line[N][N];int mac[N];int used[N];int n,m;void floyd(){ for(int i=1;i<=n;i++) { for(int j=1;j<=n;j++)

2015-07-21 21:21:20 583

原创 HDU4152-Happy 2004-积性函数和快速幂乘

题目链接http://acm.hdu.edu.cn/showproblem.php?pid=1452本题主要是积性函数和快速幂乘的运用。下面主要介绍一下积性函数:积性函数是描述因子和的一种关系:6的因子是1,2,3,6;   6的因子和是 s(6)=1+2+3+6=12;20的因子是1,2,4,5,10,20;   20的因子和是 s(20)=1+2+4+5+10+20=4

2015-07-20 16:03:21 573

原创 HDU1396:Counting Triangles -DP

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1396//根据每增加一条边所增加的正三角和倒三角的个数构造方程 #include#include__int64 dp[510];int main(){ int n; memset(dp,0,sizeof(dp)); dp[1]=1; for(int i=2;i<=500;i+

2015-07-20 09:31:14 611

转载 TCP协议知识点总结

TCP协议是我们学习工程实践的宝库,其中蕴含了很多重要的模型。有几个比较重要的机制可以研究:连接管理、可靠传输、流量控制和拥塞控制。在实现自己的功能模块的时候,可以借鉴其中的思想。连接管理: 可靠传输采用自适应的超时计算方法。流量控制使用一种基于滑动窗口协议的流量控制机制。包括接受窗口(rwnd)和发送窗口(也称为拥塞窗口:cwnd):rwnd限制发送方向网络注入报文的速率,cwn

2015-07-09 14:49:47 791

原创 hdu 1087 Super Jumping! Jumping! Jumping!-dp 最长上升子序列和

http://acm.hdu.edu.cn/showproblem.php?pid=1087 水水DP! #include #include #include #include #include #include using namespace std;int a[1010],dp[1010];int main(){ int n;

2015-04-26 22:05:51 486

原创 HDU-2544-最短路-迪杰斯特拉

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=2544 #include#include#include#include#define N 100000000using namespace std;const int MAXN=10010; int dist[MAXN],map[MAXN][MAXN];bool

2015-04-26 22:00:22 607

原创 HDU-2079-母函数

http://acm.hdu.edu.cn/showproblem.php?pid=2079 #include #include #include #include #include #include #include #include #include #include #include #include#includeusing na

2015-04-26 21:56:15 547

原创 HDU 1423 动态规划—最长公共上升子序列

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1423 说明一点:dp[i][j] 为序列1前i个元素和序列2前j个元素最长公共上升子序列多长. #include #include #include using namespace std;int n,m,a[505],b[505],dp[505][505];voi

2015-04-26 21:43:13 649

原创 HDU-1422 -重温世界杯 - 环上的最长连续子序列

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1422理解题意,没什么好说的#include#include#includeusing namespace std;const int MAX=100010;int life[MAX],cost[MAX],res[2*MAX];bool cmp(int a,int b)

2015-04-26 21:31:02 599

空空如也

空空如也

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

TA关注的人

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