HDU 2175

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

做得好辛苦的一道规律题,至于为什么辛苦。。dont ask me why。。。

n号盘子出现的位置是(1,3,5,7......)*2^(n-1)

#include <iostream>

using namespace std ;

typedef __int64 ll ;

int main()

{

    ll a[105] ;

    a[1]=1 ;

    for(int i=2 ;i<64 ;i++)

        a[i]=a[i-1]*2 ;

    ll n,m ;

    while(~scanf("%I64d%I64d",&n,&m))

    {

        if(!n && !m)break ;

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

        {

            ll temp=m/a[i] ;

            if(temp&1 && m%a[i]==0)

            {

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

                break ;

            }

        }

    }

    return 0 ;

}
View Code

 

你可能感兴趣的:(HDU)