可乐兑换
Sample Input
4 27
Sample Output
3 4 19 28
#include<stdio.h>
int k,n;
int sort(int x)
{
int t=0;
if(x<3)return 0;
while(x>=3)
{
k=k+x/3;
t=t+x%3;
x=x/3;
}
t=t+x;
if(t<3)return k;
else sort(t);
}
void main()
{
int i;
while(scanf("%d",&n)!=EOF)
{
for(i=n/2;i<=n;i++)
{
k=i;
if(n<=sort(i)){printf("%d %d\n",i,k);break;}
}
}
}