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

Re:本地编译通不过的代码居然神奇的AC,太假了~

Posted by ad315 at 2010-10-16 10:58:32 on Problem 2845
In Reply To:本地编译通不过的代码居然神奇的AC,太假了~ Posted by:iShowFun at 2009-05-20 20:14:51
> #include<stdio.h>
> #include<string>
> #include<cstring>
> #include<iostream>
> #include<algorithm>
> using namespace std;
> 
> int main()
> {
> 	int casenum;
> 	while(1==scanf("%d",&casenum))
>         {
> 		for(int c=0;c<casenum;c++)
> 		{
> 			string bin1;
> 			string bin2;
> 			string tmp;
> 			int jinwei=0;
> 			int len1;
> 			int len2;
> 			cin>>bin1>>bin2;
> 			len1=bin1.size();
> 			len2=bin2.size();
> 			if(len2<len1)
> 			{
> 				swap(bin1,bin2);
> 				swap(len1,len2);
> 			}			
> 			for(int i=0;i<len2;i++)
> 			{
> 				if(jinwei)
> 				{
> 					jinwei=1;
> 					bin2[len2-i-1]=bin2[len2-i-1]-'0'+jinwei;
> 					jinwei=bin2[len2-i-1]/2;
> 					bin2[len2-i-1]=bin2[len2-i-1]%2+'0';					
> 				}
> 				if(len1-i-1>=0)
> 				{
> 					bin2[len2-i-1]=bin2[len2-i-1]-'0'+bin1[len1-i-1]-'0';
> 					jinwei+=bin2[len2-i-1]/2;
> 					bin2[len2-i-1]=bin2[len2-i-1]%2+'0';
> 				}	
> 				if(len2-i-1==0&&jinwei)
> 				{
> 					
> 					bin2.insert(0,‘1’);//这里是有错的哦~
> 				}
> 			}	
> 			len2=bin2.size();
> 			while(bin2[0]=='0')
> 			{
> 				len2--;
> 				if(len2==0)
> 					break;
> 				bin2.erase(0,1);
> 			}
> 			cout<<c+1<<" "<<bin2<<endl;
> 		}
>         }
> 	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