11877 - The Coco-Cola Store

All about problems in Volume 118. If there is a thread about your problem, please use it. If not, create one with its number in the subject.

Moderator: Board moderators

Post Reply
saisun_7
New poster
Posts: 2
Joined: Fri Feb 06, 2015 7:21 pm

Re: 11877 - The Coco-Cola Store

Post by saisun_7 » Sun May 24, 2015 8:39 pm

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;
}
Last edited by brianfry713 on Fri Jun 19, 2015 7:06 am, edited 1 time in total.
Reason: Added code blocks

saisun_7
New poster
Posts: 2
Joined: Fri Feb 06, 2015 7:21 pm

Re: 11877 - The Coco-Cola Store

Post by saisun_7 » Sun May 24, 2015 8:39 pm

what is wrong with it?? >_<

Post Reply

Return to “Volume 118 (11800-11899)”