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 |
Re:下面是小弟写的。In Reply To:菜鸟拙见:给定N,如果S=N, S%2!=0表示到达最底层(奇数),而在上面第K层有(S-MIN)=(MAX-S)=2^(K-1).故可求。 Posted by:MasterLuo at 2008-07-08 18:11:09 while(n--) { scanf("%I64d", &s); min=max=temp=s, t=0; while(temp%2==0) { t++; temp/=2; } for(int i=t-1; i>=0; i--) { min-=a[i]; max+=a[i]; } printf("%I64d %I64d\n", min, max); } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator