SamiulSourav/uva-solutions

13059 - Tennis Championship

Closed this issue · 0 comments

using namespace std;
int main()
{
    unsigned long long x,cnt,n,s,d,mod;
    while(scanf("%llu",&n)!=EOF){
        cnt=0;
        x=n;
        while(x!=1){
            mod=x%2;
            d=x/2;
            x=x/2+mod;
            cnt+=d;
        }
        printf("%llu\n",cnt);
    }
}```