现在位置: 首页 > pletcherkyx发表的所有文章
  • 12月
  • 30日
综合 ⁄ 共 651字 评论关闭
一:log10(n!)=log10(1*2*3…*n)=log10(1)+log10(2)+…+log10(n) 二:n! = sqrt(2*π*n) * ((n/e)^n) * (1 +1/(12*n) + 1/(288*n*n) + O(1/n^3)) π = acos(-1)=3.1415927; e = exp(1)=2.718281828459; 两边对10取对数 忽略log10(1 + 1/(12*n) +1/(288*n*n) + O(1/n^3)) ≈ log10(1) = 0 得到公式 log10(n!) = log10(sqrt(2 * pi * n)) + n* log10(n / e)。 一: #include<stdio.h> #include<math.h> int main() { int i,n,t; double temp=0; scanf("%d",&t); while(t--) { temp=0; ......
阅读全文
  • 11月
  • 07日
综合 ⁄ 共 954字 评论关闭
1 Unweighted Graphs  For unweighted Graphs, a minimum  spanning tree(MST) means that a graph with minimum number of edges to connect all the vertices. the number of edges E in a minimum spanning tree is always one less than the number of vertices V: E = V – 1. The path of the DFS(depth-first search) through the graph must be a minimum spanning tree. 1.1 Java implement  public void mst() // minimum spanning tree (depth first) { // start at 0 ......
阅读全文
             Apache CXF实战之五 压缩Web Service数据                    本文链接:http://blog.csdn.net/kongxx/article/details/7530216 在现实应用中有些时候会有比较大的数据对象需要传输,或者在一个比较慢的网络环境下发布调用web service,此时可以通过压缩数据流的方式来减小数据包的大小,从而提高web service的性能。下面来看看怎样来做到这一点。 1. 首先模拟一个可以存放大数据的pojo对象,这个对象可以通过构造参数给定的size来模拟一个size大小的字符串。 [java] view plaincopyprint? package com.goo......
阅读全文
  • 05月
  • 12日
综合 ⁄ 共 361字 评论关闭
需要在播放的时候,设置一下session 的属性。         UInt32 allowMix = 1;         AVAudioSession* audioSession = [AVAudioSession sharedInstance];         [audioSession setCategory:AVAudioSessionCategoryPlayback error:nil];         AudioSessionSetProperty(kAudioSessionProperty_OverrideCategoryMixWithOthers, sizeof(allowMix), &allowMix);         [audioSession setActive:YES error:nil];
阅读全文
  • 04月
  • 27日
综合 ⁄ 共 5159字 评论关闭
http://www.cnblogs.com/cxjchen/archive/2013/05/29/3106307.html 最近在研究如何实现一个线程池。具体线程池的实现不是我想说的重点,而是关于线程的一些操作问题。 先说一下我的每个工作线程都有一个自己对应的锁,而且锁只在线程自身使用。(这方便下面的理解) 一、线程的异步取消的问题 我的线程池对外提供两个函数,create_threadpool()和destroy_threadpool()用来创建和销毁线程池,创建的过程是初始化工作线程→初始化管理线程→….工作,销毁的过程是销毁管理线程→销毁工作线程→……工作。 在这两个过程中遇到的第一个......
阅读全文
  • 04月
  • 25日
综合 ⁄ 共 2056字 评论关闭
这一题开始没有注意 at any time,题目半天没看懂啥意思。 {1,1,3,2,3}是illegal的原因是在第三个同学做题时,1已经比2多做两题了。所以为了满足任意时刻做题数目不超过1,只能一轮一轮的做,就是[1,n]的时间段里,每个人都要做一题,就是1~n的全排列。 蒟蒻表示直接对M/N组每组做了N次,再对M%N做一次。但是大神们的另一种做法要方便很多,点击打开链接 dp[i][j],i表示当前学生的状态,用二进制数表示,每一位是1就表示这个学生做过题了,j表示做到了第几题。 这一题WA了几次==是因为状态转移到dp[(1<<N)-1][j]时,这一轮......
阅读全文
  • 04月
  • 18日
综合 ⁄ 共 844字 评论关闭
以例子为主 1. 变量为空, toString() Object s =null;System.out.println(s.toString()); 2. 函数.equal 前的变量为null Object s =null;System.out.println(s.equals("a")); 3. .replace函数 ,第一个参数为空 或者 第二个参数为空 String s ="b";String str =null;String s1 =str.replace(str, s); ------------------------------------------------------------ String s =null;String str ="a";String s1 =str.replace(str, s);   4. equalsIgnoreCase函数,可将常量字符串放前面 防止出错。 String str =null;if(str.equ......
阅读全文
  • 04月
  • 15日
综合 ⁄ 共 344字 评论关闭
问题描述:已知变量X的值为2767,请编程统计变量X的二进制中有多少个一,并记入ONE变量。 分析:数值在内存中的存储本来就是二进制,所以不需要再做转换,使用移位指令统计每一位即可。 代码: data segment x dw 2767 one dw 0 data ends code segment start: assume ds:data,cs:code mov ax,data mov ds,ax mov cx,16 mov bx,x loop1: shl bx,1 jc L1 loop loop1 jmp next L1: inc one loop loop1 next: mov dx......
阅读全文
  • 04月
  • 06日
综合 ⁄ 共 1878字 评论关闭
// queuetp.h -- queue template with a nested class #ifndef QUEUETP_H_ #define QUEUETP_H_ template <class Item> class QueueTP { private:     enum {Q_SIZE = 10};     // Node is a nested class definition     class Node     {     public:         Item item;         Node * next;         Node(const Item & i):item(i), next(0){ }     };     Node * front;       // pointer to front of Queue     Node * rear;        // pointer to rear of Queue     int items;          // current number of it......
阅读全文
  • 04月
  • 03日
综合 ⁄ 共 2709字 评论关闭
500pt, 题目链接:http://codeforces.com/problemset/problem/371/A 分析:k-periodic说明每一段长度为k,整个数组被分成这样长度为k的片段,要使得修改最少,求出k长度的片段中每个位置出现次数最多的数就行。 代码: #include <vector> #include <list> #include <map> #include <set> #include <deque> #include <stack> #include <bitset> #include <algorithm> #include <functional> #include <numeric> #include <utility> #include <sstream> #......
阅读全文
  • 12月
  • 28日
综合 ⁄ 共 3409字 评论关闭
转载至:http://blog.chinaunix.net/uid-29694663-id-4329910.html 当启动一个应用程序组件时,如果该应用没有正在运行的其它程序组件,那么Android系统将为这个应用创建一个新进程(包含一个线程)用于运行应用。缺省情况下,一个应用的所有组件(Activity,Service等)运行在同一个进程和线程中(称为“主”线程)。如果在启动一个应用程序组件时,这个应用已经有进程在运行(因为有应用的其它组件存在),那么这个应用程序组件将使用同一进程和线程运行。当然你可以使用不同进程来运行不同的组件,或者在进程中创建新的线程。 ......
阅读全文
  • 12月
  • 19日
综合 ⁄ 共 386字 评论关闭
public class stringtest2 { public static void main(String[] args){ String s1 = "assabcdodijdnj"; String s2 = "dsabcdokj"; String s = method(s1,s2); System.out.println("MaxSubString:"+s); } public static String method(String s1, String s2){ for (int i = 0; i < s2.length(); i++) { for (int x =0,y=s2.length()-i;y!=s2.length()+1;x++,y++){ String sub = s2.substring(x, y); if(s1.contains(sub)){ return sub; } } } return null; } } 中间还可以加个......
阅读全文