Sunday, April 17, 2011

11933 - Splitting Numbers


#include<stdio.h>
int main()
{
    register int n,a,b,c,t;
    //freopen("in.txt","r",stdin);

    while(scanf("%d",&n)&&n)
    {
        a=c=0,t=1;b=n;
        while(b)
        {
            if(b&1)
            {
                c++;
                if(c&1)a=a|t;
            }
            t=t<<1;
            b=b>>1;
        }
        b=n-a;
        printf("%d %d\n",a,b);
    }
    return 0;
}

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.