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

wa了。。。

Posted by SignSmile at 2009-04-03 17:42:04 on Problem 1781
#include "iostream"
#include "string"
#include "math.h"
using namespace std;
int main(){
	int i;
	string str;
	while (cin >> str && str != "0e00") {
		int value = str[0]-'0';
		value = value * 10 + (str[1]-'0');
		for (i = 0;i < str[3]-'0';i++) {
			value *=10;
		}
		int n = (int)(log(value+1.0)/log(2.0)+0.00000001);
		int temp = value-(pow(2.0,n)-1);
		
		if (temp == 0) {
			cout << 2 * n - 1 << endl;
		}else{
			cout << 2 * temp - 1 << 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