现在位置: 首页 > pletcherggh发表的所有文章
  • 02月
  • 21日
综合 ⁄ 共 1684字 评论关闭
Problem Description An equal sum partition of a sequence of numbers is a grouping of the numbers (in the same order as the original sequence) in such a way that each group has the same sum. For example, the sequence:2 5 1 3 3 7 may be grouped as:(2 5) (1 3 3) (7) to yield an equal sum of 7. Note: The partition that puts all the numbers in a single group is an equal sum partition with the sum equal to the sum of all the numbers in the sequence. For this problem, you will write a program th......
阅读全文
  • 05月
  • 06日
综合 ⁄ 共 3774字 评论关闭
这篇文章转自 http://anxonli.iteye.com/blog/1097777,集中与iOS的多核编程和内存管理,大家完全可以使用苹果的多核编程框架来写出更加responsive的应用。 多核运算     在iOS中concurrency编程的框架就是GCD(Grand Central Dispatch), GCD的使用非常简单。它把任务分派到不同的queue队列来处理。开发者把任务代码装到一个个block里面,操作系统把这些任务代码分派到不同的资源里去处理,一个简单的例子来说,为什么初学者写tableview的时候,滑动列表时总会很卡,因为很多初学者把图片装载放到main thread主线程去执行,例......
阅读全文
  • 04月
  • 14日
综合 ⁄ 共 6797字 评论关闭
一致性哈希算法(Consistent Hashing Algorithm)是一种分布式算法,常用于负载均衡。Memcached client也选择这种算法,解决将key-value均匀分配到众多Memcached server上的问题。它可以取代传统的取模操作,解决了取模操作无法应对增删Memcached Server的问题(增删server会导致同一个key,在get操作时分配不到数据真正存储的server,命中率会急剧下降),详细的介绍在这篇帖子中http://www.iteye.com/topic/611976(后文指代这篇文章的地方均称为引文)。 [下面以Memcached的分布式问题为讨论点,但将Memcached server抽象为节点(Node)......
阅读全文
  • 02月
  • 23日
综合 ⁄ 共 1815字 评论关闭
先用Djikstra算出最短路径,纪录下相同的最短路径,再回溯计算花费最少的路径。 其实不用回溯,直接在比较最短路径的时候比较花费最少就可以了。 #include <iostream> #include <vector> #include <algorithm> #include <fstream> using namespace std; struct node { int index; int curDist; vector<node> preCity; node(int c, int d) : index(c), curDist(d) {} }; const int MAXINT = 0x7fffffff; int n, m, s, d; vector<vector<int>> dist; vector<vector<int>&......
阅读全文
  • 02月
  • 16日
综合 ⁄ 共 570字 评论关闭
功能:创建SIZE个线程,每个线程执行幂计算函数,然后求和。 #include <windows.h> #include <iostream> using namespace std; DWORD WINAPI Power(LPVOID n); #define SIZE 10 int main() { DWORD threadId; HANDLE handles[SIZE]; DWORD exitCode[SIZE]; for(int i=0;i<SIZE; ++i) { handles[i] = CreateThread(NULL, 0, Power, (LPVOID)i, 0, &threadId); } WaitForMultipleObjects(SIZE, handles, TRUE, INFINITE); int sum =0; for(int i=0; i<SIZE;+......
阅读全文
  • 01月
  • 29日
综合 ⁄ 共 2745字 评论关闭
Vista之家(www.vista123.com):Windows 7 研究——IE8 松散耦合进程框架探索  在2008年8月份IE8 Beta刚刚面世不久的时候,我曾经用极短的篇幅介绍了一下IE8的新的Tab控制模型(详情见:《IE8 新特性分析:IE8的稳定性源自何处》 一文)。今天,我将继续和大家分享一些最近一段时间获得的新的知识。 IE8 松散耦合进程框架,英文原文是Loosely Coupled IE (LCIE),是一种基于作业(Job)的进程管理方式。这种方式已经逐渐被各大浏览器所采用,例如Google Chrome。 下图是IE8的LCIE框架结构: 作业是Windows 2000引入的一种......
阅读全文
  • 01月
  • 26日
综合 ⁄ 共 10842字 评论关闭
段时间对Spring事务配置做了比较深入的研究,在此之间对Spring事务配置虽说也配置过,但是一直没有一个清楚的认识。通过这次的学习发觉Spring事务配置只要把思路理清,还是比较好掌握的。 总结如下: Spring配置文件中关于Spring事务配置总是由三个组成部分,分别是DataSource、TransactionManager和代理机制这三部分,无论哪种配置方式,一般变化的只是代理机制这部分。 DataSource、TransactionManager这两部分只是会根据数据访问方式有所变化,比如使用Hibernate进行数据访问时,DataSource实际为SessionFactory,TransactionMa......
阅读全文
  • 01月
  • 25日
综合 ⁄ 共 1231字 评论关闭
http://www.douban.com/group/topic/22765904/ http://www.zhihu.com/question/19872198 In the menu bar, click "File" → "New" → "New Project…". - Select "Other" under "Mac OS X". - Select "External Build System" and click "Next". - Enter the product name. - For the "Build Tool" field, type in FULL path of your python and then click "Next". Choose where to save it and click "Create". - In the menu bar, click "File" → "New" → "New File…". - Select "Other" under "Mac OS X". - Select "Empty" and......
阅读全文
  • 01月
  • 11日
综合 ⁄ 共 2182字 评论关闭
这道题的题意为:给你一个nxn的矩阵 分别代表 i到j 的距离,再给q条无向边,求使任意两个点能互相到达的最小距离 我的做法 :强连通缩点+最小生成树 //其实这题只用最小生成树可以做的 为了练习强连通而。。 1A 15MS //author: CHC //First Edit Time: 2014-05-29 21:16 //Last Edit Time: 2014-05-30 11:12 //Filename:1.cpp #include <iostream> #include <cstdio> #include <cstring> #include <cmath> #include <set> #include <vector> #include <map> #include <queue......
阅读全文
  • 12月
  • 26日
综合 ⁄ 共 2363字 评论关闭
<?php $server = "{bjmail.*.com/pop3}"; //邮件服务器 $mailbox = "inbox"; //收件箱 $mailaccount="zhao**";//用户名 $mailpasswd=" "; //密码 $stream = @imap_open($server.$mailbox,$mailaccount,$mailpasswd);//打开IMAP 连结 $mail_number = imap_num_msg($stream);//信件的个数 if($mail_number < 1) { echo "No Message for $email"; }//如果信件数为0,显示信息 for($i=$mail_number;$i>=$mail_number;$i--) { $headers = @imap_header($stream, $i); $mail_header= imap_headerinfo($stream, $i);//......
阅读全文
  • 12月
  • 19日
综合 ⁄ 共 810字 评论关闭
  #include"stdio.h"  #include"unistd.h"  #include"sys/types.h"  #include"signal.h"  #include"wait.h"   void sigchld_handler(int sig)  {      pid_t pid;      int status;      for(;(pid=waitpid(-1,&status,WNOHANG))>0;)      {          printf("child %d died :%d\n",pid,WEXITSTATUS(status));          printf("hi,parent process received SIHHLD signal successfully!\n");      }      return;  }   void main()  {      //pid_t pc,pr;      int pc=fork();      if(pc==0)      {          printf("子......
阅读全文
  • 12月
  • 17日
综合 ⁄ 共 603字 评论关闭
前言:         记得2010年刚毕业那会儿,公司做的第一个项目就用了插件的设计思想 ,最近刚好看到这方面的文章,顺便总结下。 正文:          关键思想:动态加载-->(DexClassLoader,java反射机制)        1.apk包不安装作为插件。参见 https://github.com/zz7zz7zz/android-plugin 里的git_androidplugin_apk2_demo        2.apk包需要安装作为插件。参见https://github.com/zz7zz7zz/android-plugin 里的git_androidplugin_apk_demo        3.jar包作为插件。参见https://github.com/zz7zz7zz/android-plugin 里的git_and......
阅读全文