| ||||||||||
| 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 | |||||||||
花了这么长才过...感谢想出9进制的大牛真汗,水平不够啊...转成9进制一下就好了...
#include <iostream>
#include <string>
#include <math.h>
#include <sstream>
using namespace std;
int main()
{
long num;
stringstream ss;
while(cin >> num && num != 0)
{
string s;
ss << num;
ss >> s;
ss.clear();
long sum = 0;
for(int i = 0; i < s.length(); i++)
{
char tmp = s.at(i);
long tmp2 = atoi(&tmp);
if(tmp2 >= 4)
{
tmp2--;
}
sum += tmp2 * pow(9.0, (double)s.length() - i - 1);
}
cout << atoi(s.c_str()) << ": " << sum << endl;
}
return 0;
}
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator