#include<stdio.h>
int main()
{
int n,a,b,sum;
while(scanf("%d",&n)==1)
{
if(n==0)
break;
sum=0;
while(n>2)
{
a=n%3;
b=n/3;
n=a+b;
sum=sum+b;
}
if(n==2)
sum=sum+1;
printf("%d\n",sum);
}
return 0;
}
int main()
{
int n,a,b,sum;
while(scanf("%d",&n)==1)
{
if(n==0)
break;
sum=0;
while(n>2)
{
a=n%3;
b=n/3;
n=a+b;
sum=sum+b;
}
if(n==2)
sum=sum+1;
printf("%d\n",sum);
}
return 0;
}
No comments:
Post a Comment