P9502 『MGOI』Simple Round I | A. 魔法数字 题解
一种
两边同时取对数,得:
显然,由于我们需要满足小于这个条件,而
由于我们最大化
代码非常短。
#include<bits/stdc++.h>
#define LL long long
using namespace std;
LL x;
int main()
{
cin>>x;
cout<<(long long)(log2(x-1)/2)*2;
}
一种
两边同时取对数,得:
显然,由于我们需要满足小于这个条件,而
由于我们最大化
代码非常短。
#include<bits/stdc++.h>
#define LL long long
using namespace std;
LL x;
int main()
{
cin>>x;
cout<<(long long)(log2(x-1)/2)*2;
}