http://acm.hust.edu.cn/vjudge/contest/view.action?cid=30506#problem/J
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<ctime>
#include<deque>
#include<stack>
#include<bitset>
#include<cstdio>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<numeric>
#include<sstream>
#include<utility>
#include<iostream>
#include<algorithm>
#include<functional>
using namespace std ;
int n ;
double num1[ 1000005 ] , num2[ 1000005 ] ;
int main()
{
int len = 1 ;
num1[ 1 ] = 0.5 ;
num2[ 1 ] = log10( 2.0 ) ;
while( scanf( "%d" , &n ) != EOF )
{
if( len < n )
{
for( int i = len + 1 ; i <= n ; ++i )
{
//arr[i]=arr[i-1]+(1-arr[i-1])/i/(i+1)
num1[ i ] = num1[ i - 1 ] + ( 1 - num1[ i - 1 ] ) / i / ( i + 1 ) ;
num2[ i ] = num2[ i - 1 ] + log10( 1.0 * i * i + i ) ;
}
len = n ;
}
printf( "%.6lf %d\n" , num1[ n ] , ( int )num2[ n ] ) ;
}
return 0;
}