xfstart07
Get busy living or get busy dying

#include < iostream >
using   namespace  std;

int  N;
int  ai,l;
int  n,x[ 10100 ],y[ 10100 ];
int  bsearch( int  LN){
    
int  p,q,i,L = 0 ;
    p
= 0 ; q = LN - 1 ;
    
while (p <= q){
        i
= (p + q) / 2 ;
        
++ L;
        
if (i == ai)  return  L;
        
if (ai < i) q = i - 1 ;
        
else  p = i + 1 ;
    }
    
return   0 ;
}
int  main()
{
    scanf(
" %d%d " , & ai, & l);
    N
= 1 ; n = 0 ;
    
int  ax = 0 ,ay = 0 ;
    
do {
        
int  k = bsearch(N);
        
if (k != l){
            
if (ax){
                x[
++ n] = ax; y[n] = ay;
            }
            ax
= ay = 0 ;
        }
        
else {
            
if (ax) ay = N;
            
else  ax = ay = N;
        }
        N
++ ;
    }
while (N <= 10000 );
    
if (ax){
        x[
++ n] = ax; y[n] = ay;
    }
    printf(
" %d\n " ,n);
    
for ( int  i = 1 ;i <= n; ++ i)
        printf(
" %d %d\n " ,x[i],y[i]);
    
return   0 ;
}




posted on 2009-05-28 20:18 xfstart07 阅读(192) 评论(0)  编辑 收藏 引用 所属分类: 代码库

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理