Advertisement
erfanul007

UVa 11150

Nov 25th, 2018
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.71 KB | None | 0 0
  1. #include<stdio.h>
  2. int main()
  3. {
  4. int t,k;
  5. while(scanf("%d",&t)!=EOF){
  6. int c,b,i,j;
  7. int total=t;
  8. c=t%3;
  9. if(c==0){
  10. while(t>=3){
  11. j=t/3;
  12. total=total+j;
  13. i=t%3;
  14. t=j+i;
  15. }
  16. if(t==2)
  17. total++;
  18. }
  19. else{
  20. if(c==1){
  21. b=(t+2)/3;
  22. if(b%2==0)
  23. t=t+2;
  24. }
  25. else if(c==2)
  26. t=t+1;
  27. while(t>=3){
  28. j=t/3;
  29. total=total+j;
  30. i=t%3;
  31. t=j+i;
  32. }
  33. }
  34. printf("%d\n",total);
  35. }
  36. return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement