最小乘法次数

 用递归的思想去解决
#include<stdio.h>
int count(int n)
{
    if(n==1) return 0;
    if(n%2==0) return 1+count(n/2);
    if(n%2==1) return 2+count(n/2);
}
int main()
{
    int N;
    scanf("%d", &N);
    while(N--)
    {
        int n;
        scanf("%d", &n);
        printf("%d\n", count(n));
    }
}


相关文章:

  • 2021-11-09
猜你喜欢
  • 2021-06-27
  • 2021-10-10
  • 2021-09-17
  • 2022-12-23
  • 2021-08-13
  • 2021-11-09
相关资源
相似解决方案