
Sample Output
36
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
char res[10001];
int i, carry, len = 1;
void mutiply ( int n )
{
carry = 0;
char *h = res;
for ( i = 0; i < len; i++ )
{
*h = *h * n + carry;
carry = *h / 10;
*h %= 10;
h++;
}
if ( carry != 0 )
{
*h = carry;
len++;
}
}
void f ( int n )
{
int n3, n2, i;
if ( n %2 == 0 )
{
n3 = n / 6 * 2;
n2 = n % 6 / 2;
}
else
{
n3 = ( n - 3 ) / 6 * 2 + 1;
n2 = ( n - 3 ) % 6 / 2;
}
for ( i = 1; i <= n3 / 2; i++ )
{
mutiply ( 9 );
}
if ( n3 % 2 != 0 )
{
if ( n2 > 0 )
{
mutiply ( 6 );
n2--;
}
else
{
mutiply ( 3 );
}
}
if ( n2 > 0 )
{
mutiply ( ( int ) pow ( 2.0,n2 ) );
}
}
int main()
{
int n;
res[0] = 1;
while ( scanf ( "%d",&n ) !=EOF )
{
if ( n <= 3 )
{
printf ( "%d\n", n );
continue;
}
res[0] = 1;
len = 1;
f ( n );
for ( i = len - 1; i >= 0; i-- )
{
printf ( "%d", res[i] );
}
printf ( "\n" );
}
return 0;
}



