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

大废题,用long long int直接秒过,就是偷懒用了个abs,搞了一次compile error。。。

Posted by KatrineYang at 2016-06-08 00:16:06 on Problem 1023
感觉这服务器的C++版本要更新了。。。abs(int)笨地跑的都没问题。。。
贴代妈
//============================================================================
// Name        : main1023.cpp
// Author      : 
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <string>
#include <cmath>
using namespace std;

int main() {
	int cases;
	cin >> cases;
	for(int ii = 0; ii < cases; ii++){
		int fei;
		cin >> fei;
		string np;
		cin >> np;
		int len = np.length();
		long long int tg;
		cin >> tg;
		int *nps = new int[len];
		int *res = new int[len];
		for(int i = 0; i < len; i++){
			if(np[i] == 'n') nps[len-1-i] = -1;
			else nps[len-1-i] = 1;
		}
		for(int i = 0; i < len; i++){
			int jo = tg%2;
			res[i] = jo==0? 0 : 1;
			tg = (tg-res[i]*nps[i])/2;
		}
		if(tg != 0) cout << "Impossible" << endl;
		else{
			for(int i = 0; i < len; i++) cout << res[len-1-i];
			cout << endl;
		}
		delete [] nps;
		delete [] res;
	}
	//cout << "!!!Hello World!!!" << endl; // prints !!!Hello World!!!
	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