好饼干


私信TA

用户名:uq_29131341867

访问量:988

签 名:

等  级
排  名 44383
经  验 292
参赛次数 0
文章发表 2
年  龄 0
在职情况 学生
学  校
专  业

  自我简介:

TA的其他文章

#include <stdio.h>

#include <math.h>

int main()

{


    int m=1,n=1;

    int i,j=0;

    int zui;

    while(scanf("%d%d",&m,&n)!=EOF&&m!=0&&n!=0)

    {

        int k=ceil(log2(n+1));

        int s=pow(2,k)-1;


        for(i=1;m<n;i++)

        {

            m=m*2;

            if(m>s)

            {

                m=m/2;

                break;

            }

        }

        int shendu=i;

        int cc=pow(2,shendu-1);



        if(m<=n)

        {

            if(m+cc-1<n)

            {

                zui=(pow(2,shendu)-1);

            }else{

                zui=(pow(2,shendu-1)-1)+(n-m+1);

            }

        }else{

            zui=(pow(2,shendu-1)-1);

        }

        printf("%d\n",zui);

    }

}


 

0.0分

1 人评分

看不懂代码?想转换其他语言的代码? 或者想问其他问题? 试试问问AI编程助手,随时响应你的问题:

编程语言转换万能编程问答  

代码解释器

代码纠错

SQL生成与解释

  评论区