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:终于ac了。。。心都碎了!!!!In Reply To: 帮帮偶啊!老是wa。。。。呜呜。。。跪求高人看下。。。数据都过了 Posted by:xxnan at 2010-12-08 19:44:58 > #include<stdio.h> > #include<math.h> > #define N 1000 > main() > { > int n,i,j,l1,l2,k,c[N],x; > double s1,s2,t; > char a[N],b[N]; > scanf("%d",&n); > for(i=0;i<n;i++) > { > scanf("%s%s",a,b);s1=0;s2=0; > l1=strlen(a);l2=strlen(b); > for(j=0;j<l1;j++) > { > s1=s1+(a[j]-48)*pow(2,l1-1-j); > } > for(x=0;x<l2;x++) > { > s2=s2+(b[x]-48)*pow(2,l2-1-x); > } > t=s1+s2;k=0; > if(t==0) > { > printf("%d ",i+1); > printf("0\n"); > } > else > { > while(t!=0) > { > c[k++]=(int)t%2; > t=(int)t/2; > > } > printf("%d ",i+1); > for(j=k-1;j>=0;j--) > { > printf("%d",c[j]); > > } > printf("\n"); > } > } > return 0; > } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator