0分求助
查看原帖
0分求助
847021
__zhang__楼主2024/4/6 13:07
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
ll p;long long x,n,ans2=0,sum=0;
ll ql(ll a,ll b){
	ll re=0;
	while (b){
		if(b%2)re=(re+a)%p;
		a=(a+a)%p;
		b/=2;
	}
	return re;
}
ll Pow(ll a, ll n)
{
    ll re = 1;
    while(n)
    {
        if(n % 2)re = ql(re,a)%p;
        a=ql(a,a)%p;
       	n/=2;
    }
    return re;
}
int main(){
	p=1e18;
	cin>>x>>n;
	long long ans1=Pow(2,n);
	ans2=Pow(x,2),x=Pow(x,2);
	while(ans2<ans1){
	sum++;
	ans2+=Pow(x/2,2),x=Pow(x/2,2);
	}cout<<sum;
} 
2024/4/6 13:07
加载中...