http://acm.hdu.edu.cn/showproblem.php?pid=1339

n=o*2^p,已知n,求o和p

水、、、

View Code
#include <stdio.h>
#include <string.h>
int main()
{
    int t,n;
    int cnt;
    scanf("%d",&t);
    while(t--)
    {
        scanf("%d",&n);
        if(n%2)
            printf("%d 0\n",n);
        else
        {
            cnt=0;
            while(n%2==0)
            {
                n>>=1;
                cnt++;
            }
            printf("%d %d\n",n,cnt);
        }    
    }
    return 0;
}