锘??xml version="1.0" encoding="utf-8" standalone="yes"?>漂亮人妻被中出中文字幕久久,久久午夜福利电影,精品综合久久久久久888蜜芽http://m.shnenglu.com/JonsenElizee/category/15105.htmlSoftware Developing Blog <BR> <BR> "An idea is fragile . It can be killed by a scornful smile or a yawn .It can be mound down by irony and scared to death by a cold look." <BR> "Most cultures throughout human history have not liked creative individuals .They ignore them or kill them.It is a very efficient way of stopping creativity." <BR> <BR> ------Advertising boss Charles Browe and Howard Gardner ,professor at Harvard zh-cnThu, 25 Nov 2010 20:52:41 GMTThu, 25 Nov 2010 20:52:41 GMT60How Many Times Is Needed to Pick Out The Bad Ballhttp://m.shnenglu.com/JonsenElizee/archive/2010/10/29/131709.htmlJonsenElizeeJonsenElizeeFri, 29 Oct 2010 01:21:00 GMThttp://m.shnenglu.com/JonsenElizee/archive/2010/10/29/131709.htmlhttp://m.shnenglu.com/JonsenElizee/comments/131709.htmlhttp://m.shnenglu.com/JonsenElizee/archive/2010/10/29/131709.html#Feedback0http://m.shnenglu.com/JonsenElizee/comments/commentRss/131709.htmlhttp://m.shnenglu.com/JonsenElizee/services/trackbacks/131709.htmlall the ball are the same look.
now, give you a balance, how many times do you need to pick out the bad one?

My resolution: need Ball(y) times to pick out the bad one.

#include <stdio.h>
#include 
<math.h>

int Ball(int y)
{
    
if(y <= 3return 1;
    
return 1+Ball( y/3 * 3 == y ? y/3 : y/3 +1 );
}
int main()
{
    
int i = 0;
    
for(i = 2; i < 200; i++) {
        printf(
"Ball(%3d)=%d \t", i, Ball(i));
        
if(i%5 == 0) puts("");
    }
    puts(
"");
    
return 0;
}





JonsenElizee 2010-10-29 09:21 鍙戣〃璇勮
]]>
Find Median(s) in Billion data with Memory 4Mhttp://m.shnenglu.com/JonsenElizee/archive/2010/10/28/131644.htmlJonsenElizeeJonsenElizeeThu, 28 Oct 2010 08:39:00 GMThttp://m.shnenglu.com/JonsenElizee/archive/2010/10/28/131644.htmlhttp://m.shnenglu.com/JonsenElizee/comments/131644.htmlhttp://m.shnenglu.com/JonsenElizee/archive/2010/10/28/131644.html#Feedback0http://m.shnenglu.com/JonsenElizee/comments/commentRss/131644.htmlhttp://m.shnenglu.com/JonsenElizee/services/trackbacks/131644.html鍐呭瓨鍙兘瀹圭撼100W涓暟,
鐜板湪鏈?浜挎暟,娣峰簭,
鐒跺悗姹傝繖涓浜夸釜鏁扮殑涓綅鏁?
涓綅鏁?灝辨槸涓涓湁搴忔暟緇勭殑涓棿鏁板瓧,鏁扮粍闀垮害涓哄伓鏁板氨鏄袱涓?濂囨暟鍒欏彧鏈変竴涓?

/*****************************************************************************/
/* this program should find out the median(s) in N(logN)/(logB) no matter there
/* is duplicated data or not.
/*
/* with memory limitation: 4MB memory available. in fact, it can work on 1MB.
/* I would like to express the idea with code.
/* here is just the pseudocode with out any optimization for easy understanding.
/* 
/* maybe, there is no need to check sum == N/2 or N/2+1, but this will get the 
/* median(s) as soon as possible with out more recursive invoking.
/*
/* sorry for any logical problem. please let me know if you found any.
/****************************************************************************
*/


int N = 100000000;// total data number is N
int B = 1000000;  // number of buckets.
int min, max;
scan data from 
0 to N-1 get min and max; // O(N);

// num the data number that is less than min
// min the minimum data in the target data range to find median(s)
// max the maximum data in the target data range to find median(s)
void find_median(int num=0int min, int max)
{
    
if(min == max) {
        
if(N%2) {
            print medians are min and max;
        }
        
else print median is min; // show you the result
        return// exit
    }

    
// count all the data in O(N)
    
int m = max-min > B ? ((max-min)%B ? (max-min)/B + 1 : (max-min)/B)1;
    
int cnt[B] = {0}; // count the data read.
    while(!EOF) {
        
int data = read_data()-min;
        // count data in this range [min, max]
        // data/m will get the position of data to increase the cnt[?] value
        
if(data >= min && data <= max) cnt[data/m]++;
    }
    
    
int sum = num, median_1, median_2, i = 0;
    
while(sum < N/2) sum += cnt[i++];
    i
--// median is in the range of [i*m, (i+1)*m-1]

    
/* get median(s) when sum is N/2 */
    
if(sum == N/2) {
        
if(N%2) { // N is even and there are two medians.
            median_1 = (i+2)*m-1;
            median_2 
= i*m;
            
while(!EOF) {
                
int data = read_data()-min;
                
if(data/== i) {
                    median_2 
= (data > median_2 ? data : median_2);
                }
                
if(data/== i+1) {
                    median_1 
= (data < median_1 ? data : median_1);
                }
            }
            pintf medians are median_1 and median_2;
            
return;
        }
   
       
else { // N is an odd number and there is one median.
            median_1 = (i+2)*m-1;
           
while(!EOF) {
               
int data = read_data();
               
if(data/== i+1) median_1 = (data < median_1 ? data : median_1);
            }
            print median 
is median_1;
           
return;
        }
    }

    
/* get median(s) when sum is N/2+1 */
    
if(sum == N/2+1) {
        
if(N%2) { // N is even and there are two medians.
            median_1 = i*m;
            median_2 
= i*m;
            
while(!EOF) {
                
int data = read_data();
                
if(data/== i) {
                    median_1 
= max;
                    median_2 
= (data > median_2 ? data : median_2);
                }
            }
            pintf medians are median_1 and median_2;
            
return;
        }
   
       
else {
            median_2 
= i*m; // get (N/2+1)th data.
            while(!EOF) {
               
int data = read_data();
               
if(data/== i) median_2 = (data > median_2 ? data : median_2);
            }
            print median 
is median_2;
           
return;
        }
    }

   
    
// if sum is not N/2 or (N/2 + 1), recursively to find out the median(s)
    min 
= (i+1)*m-1;
    max 
= i*m;
    
// get min and max for next processing
    while(!EOF) 
    {
        
int data = read_data()-min;
        
if(data/== i)
        {
            min 
= (data < min ? data : min);
            max 
= (data > max ? data : max);
        }
    }
    find_median(sum, min, max);
}




JonsenElizee 2010-10-28 16:39 鍙戣〃璇勮
]]>
Kth Starhttp://m.shnenglu.com/JonsenElizee/archive/2010/10/27/131505.htmlJonsenElizeeJonsenElizeeWed, 27 Oct 2010 07:18:00 GMThttp://m.shnenglu.com/JonsenElizee/archive/2010/10/27/131505.htmlhttp://m.shnenglu.com/JonsenElizee/comments/131505.htmlhttp://m.shnenglu.com/JonsenElizee/archive/2010/10/27/131505.html#Feedback0http://m.shnenglu.com/JonsenElizee/comments/commentRss/131505.htmlhttp://m.shnenglu.com/JonsenElizee/services/trackbacks/131505.html

Precondition:
    
1. star field simulation graph is planar.
    
2. the coordinate of star is (x, y) that is treated as a point銆?br>    3. N = 1000000

1. bucket-sort all points according to x-coordinate. get B buckets.
   
this is will completed in O(NlogN).
   
   
struct bucket {
    
int num;       // number of points in this bucket.
    point* points; // points in this bucket.
    double x;      // value of x-coordinate.
   }
   
   bck[B]; 
// B buckets got.

2
   
struct distance {
    point p1;
    point p2;
    
double d;     // distance between p1 and p2.
   }

   distance kdis[K]; 
// to record K small distance. and it's a eliminating-tree.
   kdis[0 to K-1= 0;

   
for(i = [0, B-2]) // O(B)
   {
    
// check bck[i] and bck[i+1]
    if(bck[i+1].x - bck[i].x >= kdis[K-1].d && kdis[K-1!= 0)
    {
        
// there is no need to check these two buckets.
        i++;
        
continue// save time.
    }

    point
* poi = bck[i].points;
    
for(j = [0, bck.num-1]) // O(N/B)
    {
        point p 
= poi[j];
        
/*
        find K points in bck[i+1] near to p
        with binary searching method 
        according to p.y.
        
*/
        kp[K]; 
// K points got in bck[i+1]

        
for(m = [0, K-1]) // O(K)
        {
            distance tmp 
= get_distance(kp[m], p);
            
if(tmp.d < kdis[K-1].d)
            {
                kdis[K
-1= tmp;
                
// adjust kdis[K-1], for it's a eliminating tree.
            }
        }
    }
   }

   
// finally, the kdis[K-1] is the kth distance in this star graph.
   
// the whole processing will be completed in O(NlogN) + O(B*N/B*K).
   
// and SC is O(N) + O(K) = O(N).

HOW TO FIND K POINTS
?
    
/*
    find K points in bck[i+1] near to p
    with binary searching method 
    according to p.y.
    
*/
it
's not complecated! and could be found in O(log(N/B)).




JonsenElizee 2010-10-27 15:18 鍙戣〃璇勮
]]>
Find kth in O(n) TChttp://m.shnenglu.com/JonsenElizee/archive/2010/10/24/131025.htmlJonsenElizeeJonsenElizeeSat, 23 Oct 2010 17:17:00 GMThttp://m.shnenglu.com/JonsenElizee/archive/2010/10/24/131025.html
Refer Find kth number in O(n) TC

#
include <stdio.h>
#include <stdlib.h>
#include <time.h>

#define N 20

void init_a(int A[])
{
  int i = 0;
  for(;i<N;i++)
    A[i] = rand()%100;
}

void print_array(int A[])
{
   int i = 0;
   for(;i<N;i++)
    {
     if(i==9)
      printf("%d\n",A[i]);
     else
      printf("%d\t",A[i]);
    }
}

void swap(int* a, int* b)
{
   int tmp = *a;
   *a = *b;
   *b = tmp;
}

int rand_partition(int A[], int start, int end)
{
   int i = start-1;
   int j = start;
   int num = rand()%(end-start+1)+start;
   swap(A+num,A+end);
   int x = A[end];
   
   for(;j<end;j++)
    {
      if(A[j]<=x)
       {
          i++;
         swap(A+i,A+j);
        }
     }
   swap(A+i+1,A+end);

   return i+1;
}


int random_select(int A[], int start, int end, int k)
{
  int i = 0;
  if(start == end)
    return A[start];
    
  int q = rand_partition(A, start, end);
   i = q-start+1;
  
  if(i == k)
    return A[q];
  else if(i<k)
    return random_select( A, q+1, end, k-i);
  else
    return random_select( A, start, q-1, k);
}

void quick_sort(int A[], int start, int end)
{
  if(start<end)
   {
     int q = rand_partition(A, start, end);
  
      quick_sort( A, q+1, end);
      quick_sort( A, start, q-1);
  }
}
   
int main(int argc, char *argv[])
{
  int A[N];
  int num = 0;
  int res = 0;
  srand((unsigned)time(NULL));
   init_a(A);
   print_array(A);
  
   num = rand()%(N-10)+5;
  printf("we begin select %d minimun number\n",num);
   res = random_select( A, 0 , N-1, num);
  printf("and num is %d\n",res);
  
   quick_sort( A, 0 , N-1);
  printf("after quick sort the array is:\n");
   print_array(A);
  system("PAUSE");    
  return 0;
}


JonsenElizee 2010-10-24 01:17 鍙戣〃璇勮
]]>
Avoiding Dupliated Computing in Fabonacihttp://m.shnenglu.com/JonsenElizee/archive/2010/10/20/130555.htmlJonsenElizeeJonsenElizeeWed, 20 Oct 2010 03:48:00 GMThttp://m.shnenglu.com/JonsenElizee/archive/2010/10/20/130555.htmlhttp://m.shnenglu.com/JonsenElizee/comments/130555.htmlhttp://m.shnenglu.com/JonsenElizee/archive/2010/10/20/130555.html#Feedback0http://m.shnenglu.com/JonsenElizee/comments/commentRss/130555.htmlhttp://m.shnenglu.com/JonsenElizee/services/trackbacks/130555.htmlfunc(n) = func(n-1) + func(n-2) + func(n-3) and func(1) == func(2) == 1 and func(3) == 2.
or function like this: fabonaci:
fabonaci(n) = fabonaci(n-1) + fabonaci(n-2).


 1 int fabo(int n, int* ptr)
 2 {
 3     printf("fabo(%d)\n", n);
 4     if(n < 3
 5     {
 6         *ptr = 1;
 7         return 1;
 8     }
 9     else {
10         int tmp;
11         *ptr = fabo(n - 1&tmp);
12         
13         return *ptr + tmp;
14     }
15 }
16 int fabonaci(int n)
17 {
18     int tmp;
19     return fabo(n, &tmp);
20 }
21 
22 int xxx(int n)
23 {
24     printf("xxx(%d)\n", n);
25     if(n < 3)return 1;
26     else return xxx(n-1)+xxx(n-2);
27 }
28 int main()
29 {
30     int n = fabonaci(10);
31     printf("n = %d\n", n);
32 
33     n = xxx(10);
34     printf("n = %d\n", n);
35     getchar();
36     return 0;
37 }

 1 /************************************************************************/
 2 /* func(n) = func(n-1) + func(n-2) + func(n-3)                          */
 3 /* func(1) = 1; func(2) = 1; func(3) = 2;                               */
 4 /************************************************************************/
 5 int funk(int n, int* n_1, int* n_2)
 6 {
 7     printf("funk(%d)\n", n);
 8     if(n == 3){
 9         *n_1 = 1;
10         *n_2 = 1;
11         return 2;
12     }
13     else{
14         int n_1_1, n_1_2;
15         *n_1 = funk(n-1&n_1_1, &n_1_2);
16         *n_2 = n_1_1;
17         return *n_1 + *n_2 + n_1_2;
18     }
19 }
20 int func(int n)
21 {
22     int n_1, n_2;
23     return funk(n, &n_1, &n_2);
24 }
25 int main()
26 {
27     int n = func(10);
28     printf("n = %d\n", n);
29     getchar();
30     return 0;
31 }



JonsenElizee 2010-10-20 11:48 鍙戣〃璇勮
]]>
漂亮人妻被中出中文字幕久久 | 久久久久久国产精品美女| 蜜桃麻豆WWW久久囤产精品| 国内精品久久久久久久影视麻豆| 亚洲av日韩精品久久久久久a| yy6080久久| 久久久久人妻一区二区三区| 精品久久久久久无码不卡| 女同久久| 波多野结衣AV无码久久一区| 久久久久久精品无码人妻| 久久精品国产日本波多野结衣| 久久精品国产99久久久古代| 欧美一区二区三区久久综合| 久久影院综合精品| aaa级精品久久久国产片| 久久国产精品-久久精品| 麻豆精品久久精品色综合| 97精品国产97久久久久久免费| 一本大道加勒比久久综合| 国产呻吟久久久久久久92| 久久婷婷五月综合成人D啪| 欧美久久久久久午夜精品| 久久婷婷五月综合成人D啪| 国产亚洲美女精品久久久2020| 久久夜色精品国产欧美乱| 日韩一区二区久久久久久| 国产高潮国产高潮久久久91 | 国产精品美女久久久久| 久久无码av三级| 久久天天躁狠狠躁夜夜2020一| av国内精品久久久久影院| 亚洲国产成人精品女人久久久| 亚洲AV无码久久精品狠狠爱浪潮| 国产一级做a爰片久久毛片| 久久精品国产亚洲精品| 久久99亚洲网美利坚合众国| 久久久久亚洲爆乳少妇无| 久久精品天天中文字幕人妻| 日产久久强奸免费的看| 热99re久久国超精品首页|