Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

大家好!能帮我看下程序为什么总是wa!谢谢了 第一次做题。。。。。

Posted by lala_lala at 2006-02-11 22:59:41 on Problem 2352
#define MAX 32768
#include<stdio.h>
int star[MAX];
int level[15001];
int main(){ 

 int i=0,pos=0,n;
 int x,y,mid,lx,a,b,r,l;
 scanf("%d",&n);
  for(i=0;i<n;i++){ 
	scanf("%d %d",&x,&y);
    pos=0;
    lx=0; 
	a=0,b=32767;
    while(1){
		mid=(a+b)/2;
		l=2*pos+1;
		r=l+1;
        if (x==mid){ 
	if (l<MAX){
            lx+=star[l]; 
            star[l]++;
            }else lx+=star[pos];
           	star[pos]++; 
		break;
	}
	if (x<mid){
	star[pos]++; 
	pos=l;
	b=mid;
	continue;            
	}
	lx+=star[l]; 
	star[pos]++;
	pos=r; 
	a=mid;
	}
	level[lx]++; 
  }
  for(i=0;i<n;i++)
       printf("%d\n",level[i]); 
  return 0;
                                            
}

Followed by:

Post your reply here:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator