| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
大废题,用long long int直接秒过,就是偷懒用了个abs,搞了一次compile error。。。感觉这服务器的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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator