Page 1 of 1

Re: 11877 - The Coco-Cola Store

Posted: Sun May 24, 2015 8:39 pm
by saisun_7

Code: Select all

#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <stack>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <set>
#include <cstring>

using namespace std;

#define pb(x) push_back(x)
#define ppb(x) pop_back(x)
#define lli long long int
#define nl puts(" ")
#define in scanf
#define spc " "

int main()
{

    int kase;
    cin>>kase;

    for(int i=0; i<kase; i++)
    {
        int n,total=0;
        int x=0;

        cin>>n;
        if(n==0) return 0;

        while(n>=3)
        {
            x=n%3;
            n=n/3;
            total=total+n;
            n=n+x;
            if(n==2) n++;
        }
        cout<<total;
        nl;


    }

    return 0;
}

Re: 11877 - The Coco-Cola Store

Posted: Sun May 24, 2015 8:39 pm
by saisun_7
what is wrong with it?? >_<