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

谁能帮我测测啊?大家发的bt数据都试过了,可就是WA

Posted by dongd at 2006-12-15 23:00:56 on Problem 1001
#include <iostream>
#include <string>
#include <vector>
using namespace std;

vector<int> expDispose(vector<int> , int );
vector<int> mul(vector<int> , vector<int> );

int main()
{
	vector<string> R;
	string S;
	int point ;
	vector<int> n;
	int i,j ,exp,flag = 0;

	while(cin >> S >> exp) 
	{
		for ( i = 0;i < 6; i ++ )
		{
			if( (S[ i ] < 0x30 || S[ i ] > 0x39 ) && S[ i ] != '.' ) 
			{
				flag = 1;
				break;
			}
		}
		if (flag == 0)
		{
			R.push_back(S);
			n.push_back(exp);
		}
		else break;
	}

	vector<string>::iterator iterR = R.begin();
	vector<int>::iterator iterN = n.begin();
	for ( ; iterR != R.end(); ++ iterR , ++ iterN )
	{
		point = 0;
		vector<int> result(6 * (*iterN));
		vector<int> intR(6) ;		

		int n0 =1;
		if(*iterN == 0) cout << n0; 
		i = 0;
		while (i < 6 && (*iterR)[ i ++ ] != '.') ;
		if ( i == 6) j = 5;
		else j = 4;
		for ( i = 0; i < 6; i ++ )
		{
			if( (*iterR)[ i ] != '.' )					
			{
				intR[ j ] = (*iterR)[ i ] - 0x30;
				j --;	
			}
			else
				point = 5 - i;	
		}
		
		result = expDispose(intR, *iterN);
		

		j = point * (*iterN) ;		
		if( point == 0)
		{
			i = 5 * (*iterN) - 1;
		}
		else
			i = 6 * (*iterN) - 1;
		
		while (result[ i ] == 0 && i > j ) i --;
		int end = 0 ;
		while (result[ end ] == 0 && end < j) end ++;
			
		for(;i >= end; i --)
		{
			cout << result[ i ];
			if (i == j && end != j)
			cout << ".";
		}
		cout  << endl;
		
	}

	return 0;
}

	vector<int> mul(vector<int> v1, vector<int> v2)
	{
		int jinwei;
		int i,j;
		vector<int> result(v1.size() + v2.size());

		int t1 = v1.size() - 1;
			while(v1[ t1 ] == 0) t1 -- ;
		int	t2 = v2.size() - 1;
			while(v2[ t2 ] == 0) t2 --;	
		for ( i = 0; i <= t1; i ++ )
		{
			jinwei = 0;						
			for ( j = 0 ;j <= t2 ; j ++)
			{
				int x = v2[ j ] * v1[ i ] + jinwei + result[ j + i ];
				result[ j + i ] = x % 10;
				jinwei = x / 10;				
			}
			if(jinwei != 0) result[ j + i ] = jinwei;
		}

		return result;
	}

	vector<int> expDispose(vector<int> R, int n)
	{
		vector<int> result(R.size() * n);
		if (n >= 2) 
		{
			if (n % 2 == 1)
				result = mul(R,expDispose(R,n-1));
			else
				result = expDispose(mul(R,R), n / 2);
		}
		else 
			result = R;
		return result;

	}

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