上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 53 下一页

2013年8月23日

URAL 1586

摘要: 题目大意:求出n位十进制数中每相邻三位均为一个三位数素数的个数对10^9+9取模的值。Time Limit:1000MSMemory Limit:65536KB64bit IO Format:%I64d & %I64u 数据规模:3#include#include#include#include#include#include#include#include#includeusing namespace std;typedef double db;#define DBG 0#define maa (1>| "#define pr(x) #x"=" i 阅读全文

posted @ 2013-08-23 18:40 bbsno 阅读(156) 评论(0) 推荐(0)

python 连接MS sql server2005数据库

摘要: 在google上有个开源的项目叫pymssql项目地址:https://code.google.com/p/pymssql/看来段代码import pymssqlconn = pymssql.connect(host='192.168.1.1',port='1433', user='user', password='password', database='mydatabase', as_dict=True)cur = conn.cursor()cur.execute('SELECT * FROM pers 阅读全文

posted @ 2013-08-23 18:38 bbsno 阅读(309) 评论(0) 推荐(0)

UVA 10054项链(欧拉回路)

摘要: 回路条件:1.所有点的度数必须为偶数。2.图必须连通。3.图必须首尾相接。思路:先统计度数,度数全为偶数,则找任意一点一路搜下去,并将搜到的边保存, 如果最后保存的边不足n条,说明图不连通,如果是n条,判读是第一条和最后一条是否相接。#include #include #include using namespace std;struct edge{ int x,y;};int a[55][55],du[55];vector my;void jie(int u) //一路接下去,如果可以组成回路,肯定可以接出一条路径 { edge t; for(int v=1;v>t; while(t- 阅读全文

posted @ 2013-08-23 18:36 bbsno 阅读(170) 评论(0) 推荐(0)

opencv 仿射变换 计算旋转矩阵源码分析

摘要: 在使用opencv进行仿射变换的时候,会先计算一个放射变换矩阵,获取放射变换矩阵的函数原型: /* Computes rotation_matrix matrix */CVAPI(CvMat*) cv2DRotationMatrix( CvPoint2D32f center, double angle, double scale, CvMat* map_matrix ); 这个函数的实现为: CV_IMPL CvMat*cv2DRotationMatrix( CvPoint2D32f center, double angle... 阅读全文

posted @ 2013-08-23 18:34 bbsno 阅读(1443) 评论(0) 推荐(0)

hdu 4427 Math Magic

摘要: dp[i][j][k]为i个数,和为j,最小公倍数为k,满足的个数。dp[i+1][j+v][ lcm[k][v] ]+=dp[i][j][k]4层for循环,枚举i,j,k,v,朴素肯定超时,加上优化。首先可以预处理1000以内每两个数的最小公倍数。其次,枚举v的时候,只需要枚举m的因子就够了,因为他们要构成最小公倍数为m,必须每个数都是m的因子。这样的话k和j的枚举都降到很小了。由于100*1000*1000的int开不下,观察转移方程,i+1只和i有关,所以可以采用滚动数组。不加上面的优化,很容易超时。#include#include#include#include#include#in 阅读全文

posted @ 2013-08-23 18:31 bbsno 阅读(116) 评论(0) 推荐(0)

利用Java NIO 实现client端,支持自动重连

摘要: Java NIO 实现client端,相比较于Server端的实现,相对简单,如果要支持自动重新连接功能,就需要有线程同步的概念。以下代码实现了自动重新连接的功能,增加了一个具体的连接管理类Manager。package com.sof.nio;import java.io.IOException;import org.slf4j.Logger;import org.slf4j.LoggerFactory;import com.sof.bas.Config;import com.sof.exe.Client;public class Manager implements Runnable { 阅读全文

posted @ 2013-08-23 18:29 bbsno 阅读(1972) 评论(0) 推荐(0)

树上计数-hdu-4705-Y

摘要: 题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4705 题目大意:给一棵树,求三点不能通过简单路径到达的种数(也就是不在一条线上)。解题思路:如果枚举Y形的话,要先枚举一个点,然后在子树中找三个点,这样找有点麻烦,复杂度应该为o(n^2)。如果求补集,找三点在一条线的情况就好找了,枚举中间的那个点还剩下两个点,直接o(n)就可以解决(每次计算当前子树到和前面子树)。PS:树上计数:递归+dp+数学。一般都能很好解决。遍历树只用记录父亲节点判有没访问即可。代码:#include#include#include#include#include#inc 阅读全文

posted @ 2013-08-23 18:27 bbsno 阅读(142) 评论(0) 推荐(0)

【C/C++】内存分配函数:malloc,calloc,realloc,_alloca

摘要: 【C/C++】内存分配函数:malloc,calloc,realloc,_allocamalloc:原型:extern void *malloc(unsigned int num_bytes); 头文件:在TC2.0中可以用malloc.h或 alloc.h (注意:alloc.h 与 malloc.h 的内容是完全一致的),而在Visual C++6.0中可以用malloc.h或者stdlib.h。 功能:分配长度为num_bytes字节的内存块 返回值:如果分配成功则返回指向被分配内存的指针(此存储区中的初始值不确定),否则返回空指针NULL。当内存不再使用时,应使用free()函数将内存 阅读全文

posted @ 2013-08-23 18:25 bbsno 阅读(151) 评论(0) 推荐(0)

北大 ACM 1007 DNA Sorting

摘要: DNA SortingTime Limit: 1000MSMemory Limit: 10000KTotal Submissions: 75079Accepted: 30074Description One measure of ``unsortedness'' in a sequence is the number of pairs of entries that are out of order with respect to each other. For instance, in the letter sequence ``DAABEC'', this 阅读全文

posted @ 2013-08-23 18:22 bbsno 阅读(151) 评论(0) 推荐(0)

system2之:6 计划任务

摘要: 计划任务 at 一次性 crontab 周期性 * 一次性任务设置: at或batch命令 at和batch都依赖于系统的atd这个系统服务 RHEL5默认是启动了的,如果没启动,可以用以下命令启动 at和batch的区别是什么?? 最大区别就是batch执行时会根据系统的工作负载大小选择到底该不该执行,而at没有这个考虑。 [root@host log_bak]# chkconfi... 阅读全文

posted @ 2013-08-23 18:20 bbsno 阅读(327) 评论(0) 推荐(0)

上一页 1 ··· 5 6 7 8 9 10 11 12 13 ··· 53 下一页

导航