PS: POJ1131就是ZOJ1086,参看ZOJ1086的解题报告.
Run ID User Problem Result Memory Time Language Code Length Submit Time
3064805 princetonboy 1131 Accepted 220K 0MS C++ 972B 2008-01-29 20:52:41
My Code:
#include<iostream>
#include<string>
#include<vector>
using namespace std ;
int main()
{
string str ;
vector <int> v ;
while(cin >> str)
{
if(cin.fail()) break ;
str = str.substr(2) ;
v.clear() ;
for(int i = (int) str.size()-1 ; i >= 0 ; i --)
{
int m , n = str[i] - 48 ;
int len = (int) v.size() ;
for(int j = 0 ; j < len ; j ++)
{
m = n*10 + v[j] ;
v[j] = m / 8 ;
n = m % 8 ;
}
while(n != 0)
{
n *= 10 ;
v.push_back(n/8) ;
n %= 8 ;
}
}
cout << "0." << str << " [8] = 0." ;
for(i = 0 ; i < (int) v.size() ; i ++)
cout << v[i] ;
cout << " [10]" << endl ;
}
return 0 ;
}