Page 1 of 1

uva 11150-cola, getting Time limit error but why!!!

Posted: Sat Jul 01, 2017 11:08 pm
by leocris
#include <stdio.h>
int main()
{
int a,c,n,b,sum;
while(1){scanf("%d", &n);
c=n;
sum=0;
while(n>=3){
sum=n/3+sum;
n=n/3+n%3;
}

if(n==2) {printf("%d\n",sum+c+1);}
else printf("%d\n",sum+c);
}
return 0;

}