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;
} 

 

相关文章:

  • 2022-01-27
  • 2022-02-19
  • 2021-11-07
  • 2022-12-23
  • 2021-12-29
  • 2021-11-13
  • 2021-12-12
  • 2021-10-13
猜你喜欢
  • 2022-12-23
  • 2022-02-12
  • 2021-09-19
  • 2022-12-23
  • 2021-10-10
  • 2021-10-03
相关资源
相似解决方案