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

50题,纪念一下。。。。。。

Posted by 274856653 at 2019-01-09 16:08:26 on Problem 1060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <bitset>
using namespace std;

#define N  2002

void trim(string &s)
{
		int index = 0;
		if( !s.empty())
		{
				while( (index = s.find(' ',index)) != string::npos)
				{
						s.erase(index,1);
				}
		}

}
int main()
{
		int iTNum = 0; 

		string sTNum;
		getline(cin,sTNum);
		iTNum = atoi(sTNum.c_str());
//		cout<<"sTNum is "<<sTNum<<endl;
//		cout<<"iTNum is "<<iTNum<<endl;
		for(int i = 0; i<iTNum; i++)
		{
			//	cout<<"i is"<<i<<endl;
				string s1;
				getline(cin,s1)	;

				int index = s1.find(" ");
				string sTemp = s1.substr(0,index);
				int iFxDegree = atoi(sTemp.c_str());
				
				s1 = s1.substr(index);
				trim(s1);
			//	cout<<" iFxDegree is  " <<iFxDegree <<" s1 is " <<s1<<" index is " <<index<<endl;

				bitset<N>Fx(s1);
			//	cout<<" Fx is "<<Fx<<endl;


				string s2;
				getline(cin,s2)	;

				index = s2.find(" ");
				sTemp = s2.substr(0,index);
				int iGxDegree = atoi(sTemp.c_str());

				s2 = s2.substr(index);
				trim(s2);
			//	cout<<" iGxDegree is  " <<iGxDegree <<" s2 is " <<s2<<" index is "<<index<<endl;

				bitset<N>Gx(s2);
			//	cout<<" Gx is "<<Gx<<endl;

				string s3;
				getline(cin,s3)	;

				index = s3.find(" ");
				sTemp = s3.substr(0,index);
				int iHxDegree = atoi(sTemp.c_str());

				s3 = s3.substr(index);
				trim(s3);
			//	cout<<" iHxDegree is  " <<iHxDegree <<" s3 is " <<s3<<" index is "<<index<<endl;

				bitset<N>Hx(s3);
			//	cout<<" Hx is "<<Hx<<endl;
			
				bitset<N>Multi;
				int iFlag = 0;
				for(int j = 0; j<iGxDegree; j++)
				{
				//		cout<<" j is "<<j <<" Gx[j] is "<<Gx[j]<<endl;
						if(1==Gx[j])
						{
								bitset<N>bTemp;
								bTemp = (Fx<<j);
				//				cout<<"bTemp is " <<bTemp<<endl;
								if(0 == iFlag)
								{
										Multi = bTemp;
										iFlag = 1;
								}else
								{
										Multi = (Multi ^ bTemp);
								}
				//				cout<<"Multi is " <<Multi<<endl;
						}
				}
			
				int iMultiDegree = 0;
				for(int j = N -1; j>=0; j--)
				{
						if(Multi.test(j))
						{
								iMultiDegree = j +1;
								break;
						}

				}
				//cout<<" iMultiDegree is "<<iMultiDegree<<endl;

				iFlag = 0;
				while(1)
				{
				//		cout<<" iMultiDegree is "<<iMultiDegree<<" iHxDegree is "<<iHxDegree <<endl;
						if(iMultiDegree < iHxDegree )
						{
				//				cout<<" the endl"<<endl;
								break;
						}
						int iDiff = iMultiDegree - iHxDegree;

				//		cout<<"iDiff is " <<iDiff<<endl;
						bitset<N>bTemp;
						bTemp = (Hx<<iDiff);

				//		cout<<"bTemp is " <<bTemp<<endl;
						Multi = (Multi ^ bTemp);

				//		cout<<"Multi is " <<Multi<<endl;

						for(int j = N -1; j>=0; j--)
						{
								if(Multi.test(j))
								{
										iMultiDegree = j +1;
										break;
								}

						}

				}

				cout<<iMultiDegree;
				for(int j = iMultiDegree -1; j>=0; j--)
				{
						cout<<" "<<Multi[j];
				}
				cout<<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