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:1001题:有牛人帮我看下不,提交总是wrong answer

Posted by 20085753 at 2010-04-23 22:39:11 on Problem 1001
In Reply To:有牛人帮我看下不,提交总是wrong answer Posted by:20085753 at 2010-04-23 22:38:13
> #include <iostream>
> #include <vector>
> #include <string>
> using namespace std;
> 
> void fun(string r, int n){
> 	vector<int> arr;
> 	int point = 0;
> 	for(int k = r.size() - 1; k >= 0; k--){
> 		if(r[k] != '.')
> 			arr.push_back(r[k] - 48);
> 		else
> 			point = r.size() - k - 1;
> 	}
> 	int temp = 0, carry = 0, num = n;
> 	vector<int> brr = arr;
> 	vector<int> crr = arr;
> 	while(--num){
> 		for(unsigned int i = 0; i < brr.size(); i++){
> 			for(unsigned int j = 0; j < crr.size(); j++){
> 				temp = brr[i] * crr[j] + carry;
> 				if(i == 0)
> 					arr[j] = temp % 10;
> 				else if(j + i < arr.size()){
> 					temp += arr[i + j];
> 					arr[i + j] = temp % 10;
> 				}
> 				else
> 					arr.push_back(temp % 10);
> 				carry = temp / 10;
> 			}
> 			while(carry){
> 				temp = carry % 10;
> 				arr.push_back(temp);
> 				carry /= 10;
> 			}	
> 		}
> 		crr = arr;
> 	}
> 	int leng = 0, stats = 0;
> 	for(unsigned int x = 0; x < arr.size(); x++){
> 		if(stats == 0 && arr[x] == 0)
> 			leng++;
> 		else{
> 			stats++;
> 			if(x == arr.size() - point * n + leng - 1 && point != 0)
> 				cout << arr[arr.size() - stats] << ".";
> 			else
> 				cout << arr[arr.size() - stats];
> 		}
> 	}
> 	if(leng == arr.size())
> 		cout << 0;
> 	cout << endl;
> }
> int main(){
> 	string r;
> 	int n;
> 	while(cin >> r >> n)
> 		fun(r, n);
> 	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