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 |
为什么错?大牛来看看或者给点测试数据?#include <stdio.h> __int64 lst[33]={2}; __int64 findn(__int64 root) { int i; for (i=0;i<33;i++) { if (lst[i]>root) { if (lst[i]-root<root-lst[i-1]) return lst[i]-root; else { if (root-lst[i-1]!=0) return root-lst[i-1]; else return lst[i]-root; } } } } void findlr(__int64 root,__int64 n,__int64 &l,__int64 &r) { while (n/=2) { l-=n; r+=n; } } void main() { __int64 N,i,root,n,l,r; for (i=1;i<33;i++) lst[i]=lst[i-1]*2; scanf("%I64d",&N); while (N--) { scanf("%I64d",&root); l=r=root; if (root%2==0) { n=findn(root); findlr(root,n,l,r); } printf("%I64d %I64d\n",l,r); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator