Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- int main()
- {
- int t,k;
- while(scanf("%d",&t)!=EOF){
- int c,b,i,j;
- int total=t;
- c=t%3;
- if(c==0){
- while(t>=3){
- j=t/3;
- total=total+j;
- i=t%3;
- t=j+i;
- }
- if(t==2)
- total++;
- }
- else{
- if(c==1){
- b=(t+2)/3;
- if(b%2==0)
- t=t+2;
- }
- else if(c==2)
- t=t+1;
- while(t>=3){
- j=t/3;
- total=total+j;
- i=t%3;
- t=j+i;
- }
- }
- printf("%d\n",total);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement