现在位置: 首页 > gallup发表的所有文章
  • 08月
  • 19日
算法 ⁄ 共 1243字 评论关闭
题目链接:poj 3764 The xor-longest Path 题目大意:给定一棵树,每条边上有一个权值,找出一条路径,使得路径上权值的亦或和最大。 解题思路:dfs一遍,预处理出每个节点到根节点路径的亦或和rec,那么任意路径均可以表示rec[a] ^ rec[b],所以问题 就转换成在一些数中选出两个数亦或和最大,那么就建立字典树查询即可。 #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int maxn = 100005 * 32; const int sigma_size = 2; struct Tire { int sz; int......
阅读全文
  • 07月
  • 26日
综合 ⁄ 共 674字 评论关闭
Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine if the input string is valid. The brackets must close in the correct order, "()" and "()[]{}" are all valid but "(]" and "([)]" are not. 思路:这道题可以用栈来做。比如"("、“["、"{"表示压栈的操作,另外三个字符表示出栈的操作。当来一个出栈的字符,将栈顶元素出栈,看其是否匹配,不匹配则false,匹配则继续,直到string到尾部并且栈为空。 class Solution { public: bool isPush(char a) { if (a......
阅读全文
  • 04月
  • 03日
综合 ⁄ 共 717字 评论关闭
规律简单 最后每项要加的最终系数为    c(n-1,i) / 2^(n-1);累加求和即可,但因为系数直接算出会出现精度问题,用大数会超时的,所以从求x 改求exp(log(sum)); #include <cstdio> #include <cstring> #include <iostream> #include <vector> #include <cmath> using namespace std; typedef long long LL; const int maxn = 50005; double a[maxn]; int n; //void cal(){ // double p = 1; // for(int i=1;i<n;i++) p/=2; // double res = 0; // for(int i=0;......
阅读全文
  • 03月
  • 24日
综合 ⁄ 共 73字 评论关闭
材质分为:不锈钢 铁 外形分为:机芽 自攻,机芽比自攻的螺纹细密。 头分为:圆头 平头 参数: M1.4*3:直径1.4mm,长3mm. 类似的有 M1.4*5    
阅读全文
// // // // // // // // // ///2013.1.24 // // // // // // // // // 这一个设计模式有以下三种分支: One-way adapter; Two-way adapter; Pluggable adapter。 鉴于本文面向较为基础, 最后一个暂且不表。 如果有兴趣,可以上网寻找更多相关资料。 【核心】将用户的需求与一个已经存在的实体(Adaptee)所适配的一个转换器。 来看一下UML图: 一个很简单的例子, 就是插座的接口了。 有些电器为二眼插头接口, 但很不巧, 家里的插座只能插三眼插头, 怎么办呢?(不要说换插座) 这时候就需要......
阅读全文
  • 09月
  • 29日
综合 ⁄ 共 1134字 评论关闭
        问题起源于编程珠玑Column 12中的题目10,其描述如下:   How could you select one of n objects at random, where you see the objects sequentially but you do not know the value of n beforehand? For concreteness, how would you read a text file, and select and print one random line, when you don’t know the number of lines in advance?   问题定义可以简化如下:在不知道文件总行数的情况下,如何从文件中随机的抽取一行?         首先想到的是我们做过类似的题目吗?当然,在知道文件行数的情况下......
阅读全文
  • 09月
  • 07日
综合 ⁄ 共 320字 评论关闭
肖锐(Cooki)个人原创,欢迎转载,转载请注明地址,肖锐(Cooki)的技术博客 http://blog.csdn.net/xiao0026 UIWebView清除缓存:   加入以下代码: [[NSURLCache sharedURLCache] removeAllCachedResponses]; 清除Cookie  //有点像我的名字,哈哈 NSHTTPCookie *cookie; NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCookieStorage]; for (cookie in [storage cookies]) { [storage deleteCookie:cookie]; }
阅读全文
猛戳这里: https://code.google.com/p/mypomodoro/downloads/detail?name=myPomodoro-2.1-beta.dmg&can=2&q= 不用再找其他的了
阅读全文
  • 05月
  • 07日
综合 ⁄ 共 3606字 评论关闭
命令: show processlist; 如果是root帐号,你能看到所有用户的当前连接。如果是其它普通帐号,只能看到自己占用的连接。 show processlist;只列出前100条,如果想全列出请使用show full processlist;  mysql> show processlist;   命令: show status; 命令:show status like '%下面变量%'; Aborted_clients 由于客户没有正确关闭连接已经死掉,已经放弃的连接数量。  Aborted_connects 尝试已经失败的MySQL服务器的连接的次数。  Connections 试图连接MySQL服务器的次数。  Created_tmp_tables 当执行语句时,已经被创......
阅读全文
  • 05月
  • 06日
综合 ⁄ 共 555字 评论关闭
应公司要求,迎接世博400天,给网监做个网站,功能很是强大,时间一月,手头还有一大堆需求要做,合计了下去网上找个cms系统来应付。于是有了以下三个搭档。   phpcms2008 UCenter 1.5.0 Discuz! 7.0.0   参考了 http://blog.sina.com.cn/s/blog_56f150e70100bi8t.htmlhttp://www.68start.com/cms/phpcms/200812/13-14711_2.html 这两篇文章     首先下载安装以上三个软件 Discuz 和 UCenter 整合很简单,安装时按提示即可。   1. PHPCMS设置 进入管理后台 我的面板-->网站配置-->通行证-->Ucenter Client 配置 设置 正向......
阅读全文
  • 04月
  • 20日
综合 ⁄ 共 5597字 评论关闭
NAT原理分析 关键词: NAT,NATP 摘要: 缩略语: NAT: Network Address Translator NAPT:Network Address Port Translator ALG:Application Specification Gateway 1. 概述 NAT(Network Address Translation),中文称为:网络地址转换器,其基本的含义指互联网络中的中继设备在转发分组时改变分组的网络层地址、甚至上层地址的一种方法。NAT的实现并没有统一的规范,各个产品(包括Linux)根据应用的需要独立完成。IETF的NAT工作组在2001年推出Traditional IP NAT的RFC,其中阐述了Basic Network Address Translation和Netw......
阅读全文
  • 02月
  • 20日
综合 ⁄ 共 701字 评论关闭
给定a,b两个长度不一的字符串,a>b,判断b中的每个字符是否都在a中。 bool sc(string &a , string &b) { int have[26] = {0}; for ( int i = 0 ; i < a.size() ;++i) have[a[i]-'A'] = 1 ; for ( int i = 0 ; i < b.size() ;++i) if(have[b[i]-'A'] == 0) return false ; return true ;// a中可出现重复字符 } bool sc ( string &a , string &b) { bool f1[26] = {false}; bool f2[26] = {false}; bool f = false ; for ( int i =......
阅读全文