Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
大家好!能帮我看下程序为什么总是wa!谢谢了 第一次做题。。。。。#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator