上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 300 下一页
2013年10月31日

找出两个排好序的数组的中位数

摘要: 在LeetCode上看到的一道题目:给定两个数组大小分别为m和n,排好了序,可能是降序也可能是升序,求两个数组所有数字的中位数,要求算法复杂度为O(m+n)。这里的中位数是如下定义的:如果总个数为偶数那么就取第n/2和n/2+1个数的平均数,例如: 两个数组分别为:[1,2] 和[1,2]那么中位数就应该是1,1,2,2的中位数,也就是:1.5对于这个题目,最简单的做法自然是将两个数组在O(m+n)时间内分别整理成升序排列,然后合并两个数组到一个大的数组C里面,最后直接求C的中位数即可,这个做法的代码我就不写出来了,还是比较容易写的,但是最大的缺点在于:浪费空间,数组C的使用就导致内存多了m+ 阅读全文
posted @ 2013-10-31 22:13 you Richer 阅读(1042) 评论(0) 推荐(0) 编辑

mysql中设置默认字符编码为utf-8

摘要: 使用过Linux的同志就知道,在Linux下安装mysql,尤其是使用yum安装的时候,我们是没法选择其默认的字符编码方式。这个就是一个比较头痛的问题,如果Linux数据库中使用到中文的时候,乱码问题会让你很头痛。今天就来先说说Linux下怎么设置其默认编码方式。1、首先中止其mysql服务,需要在root权限下 service mysqld stop 2、在/etc/下面找到my.cnf文件,如果没有,找到mysql的安装目录下的support-files文件夹下的my-medium.cnf文件,复制到/etc/下面并改名为 my.cnf3、编辑my.cnf文件,在其[client] 和 . 阅读全文
posted @ 2013-10-31 22:12 you Richer 阅读(383) 评论(0) 推荐(0) 编辑

大步小步攻击算法_完全版

摘要: 不错的大步小步算法,可以秒掉poj_2417,poj_3243这种题struct hash{ int a, b, next;} Hash[MAXN >= 1; } return ret;} //A^x=B(mod C)//使用前先B%=Cint BabyStep(int A, int B, int C){ top = MAXN, ++idx; LL buf = 1 % C, D = buf, K; int i, tmp, d = 0; for (i = 0; i = 0 && (w = find(tmp)) != -1) retu... 阅读全文
posted @ 2013-10-31 22:11 you Richer 阅读(348) 评论(0) 推荐(0) 编辑

ACL登陆认证

摘要: 前篇文章ACL授权实例介绍了授权,授权完成之后,就要进行认证。ACL的认证主要分为登陆认证与即时认证。所谓登录认证就是在用户登陆的时候,进行信息认证。根据用户Id,加载上来该用户所拥有的权限模块;而即时认证指的是用户对某一模块或记录是否有增删改查的权限。 首先来看登录认证。下面是manager层ACLManager中有关登陆授权的信息。 package com.lzq.manager.impl;/** * 认证管理实现 * @author lzq * */public class ACLManager extends AbstractPageManager { /** * 搜索某个用户拥有.. 阅读全文
posted @ 2013-10-31 22:07 you Richer 阅读(1194) 评论(0) 推荐(0) 编辑

fully delete project in Eclipse

摘要: 选择你的项目(test)右击,选择delete——弹出框中勾选删除全部,如下如所示: 正常情况下,这样就能删除干净了,有时候你项目在运行,这时候你点击删除,那就会报下面的错误提示,虽然不会影响你其它项目的运行,但是心里是不是很不爽呢? java.lang.IllegalArgumentException: Document base D:\work3.7\.metadata\.plugins\org.eclipse.wst.server.core\tmp1\wtpwebapps\l你项目名称 does not exist or is not a readable directory at... 阅读全文
posted @ 2013-10-31 22:05 you Richer 阅读(225) 评论(0) 推荐(0) 编辑

【PAT Advanced Level】1014. Waiting in Line (30)

摘要: 简单模拟题,注意读懂题意就行#include #include using namespace std;#define CUSTOMER_MAX 1000+1#define INF 0x6fffffff #ifndef LOCAL// #define LOCAL#endif LOCALint n; // number of windows que[20];queueWait[20];int currTime = 0;int LeaveTime[CUSTOMER_MAX];int Timebase[20] = {0};int main(){#ifdef LOCAL freopen("i 阅读全文
posted @ 2013-10-31 22:03 you Richer 阅读(217) 评论(0) 推荐(0) 编辑

LIRe 源代码分析 2:基本接口(DocumentBuilder)

摘要: 本文分析LIRe的基本接口。LIRe的基本接口完成的工作不外乎两项:生成索引和检索。生成索引就是根据图片提取特征向量,然后存储特征向量到索引的过程。检索就是根据输入图片的特征向量到索引中查找相似图片的过程。LIRe的基本接口位于net.semanticmetadata.lire的包中,如下图所示: 将这些接口分为2类:DocumentBuilder:用于生成索引ImageSearcher:用于检索 下面来看看与DocumentBuilder相关的类的定义:(LIRe在代码注释方面做得很好,每个函数的作用都写得很清楚)DocumentBuilder:接口,定义了基本的方法。AbstractDo. 阅读全文
posted @ 2013-10-31 22:01 you Richer 阅读(418) 评论(0) 推荐(0) 编辑

UVa 10006 - Carmichael Numbers

摘要: 题目:判断一个数是不是Carmichael number。分析:数论。利用素数的随进判定算法,可以通过判定并且不是素数的数称为Carmichael number。 首先,利用筛法对素数进行打表。 然后,利用费马小定理枚举所有的a进行判断。#include #include #include using namespace std;typedef long long LL;int prime[65000];LL powmod( int a, int n, int m ){ if ( n == 1 ) return a%m; LL x = powmod( a, n/2, m )... 阅读全文
posted @ 2013-10-31 21:59 you Richer 阅读(271) 评论(0) 推荐(0) 编辑

date(): It is not safe to rely on the system’s timezone settings.

摘要: 在执行php脚本时出现的错误:date(): It is not safe to rely on the system’s timezone settings.You are *required* to use the date.timezone setting or the date_default_timezone_set() function. In case you used any of those methods and you are still getting this warning, you most likely misspelled the timezone ident 阅读全文
posted @ 2013-10-31 21:57 you Richer 阅读(201) 评论(0) 推荐(0) 编辑

oracle 游标实现多重循环

摘要: declare -- Local variables here i integer; cursor c_province is select ds.swjg_dm from dm_swjg ds where ds.swjg_dm!=0; cursor c_year is select distinct yh.tjyf from ygz_hs yh where yh.tjyf like '2013%' group by yh.tjyf; begin -- Test statements here i:=0; for cp in c_province loop for c... 阅读全文
posted @ 2013-10-31 21:55 you Richer 阅读(436) 评论(0) 推荐(0) 编辑
上一页 1 ··· 7 8 9 10 11 12 13 14 15 ··· 300 下一页